如何解决运行ruby测试时,在$ PATH中找不到Jenkinsfile docker exec错误可执行文件
我在Jenkinsfile中有一个阶段,可以使用rake test运行一些ruby测试文件。但是测试花费的时间太长,因此我计划实现单个测试的并行运行。但是在并行执行各个测试时遇到错误。
当我们位于rake test
文件夹中时,所有测试用例都使用lib
运行。
当我们位于ruby test1.rb
文件夹中时,使用lib/test
来运行各个测试用例。
当前正在运行的Jenkinsfile:
stage('Test Image') {
steps {
script {
sh "docker run --rm --entrypoint '' -v \${AWS_CONFIG_FILE:-/home/ubuntu/.aws/config}:/root/.aws/config:ro -v \${AWS_SHARED_CREDENTIALS_FILE:-/home/ubuntu/.aws/credentials}:/root/.aws/credentials:ro -v ${WORKSPACE}/test-results:/srv/www/lib/test/html_reports ${IMAGE_NAME} rake test"
}
}
}
通过并行测试修改的Jenkinsfile:
stage('Test the Image') {
parallel {
stage('Test1'){
steps {
script {
sh "docker run --rm --entrypoint '' -v \${AWS_CONFIG_FILE:-/home/ubuntu/.aws/config}:/root/.aws/config:ro -v \${AWS_SHARED_CREDENTIALS_FILE:-/home/ubuntu/.aws/credentials}:/root/.aws/credentials:ro -v ${WORKSPACE}/test-results:/srv/www/lib/test/html_reports docker exec -it ${IMAGE_NAME} bash -c 'cd test && ruby test1.rb'"
}
}
}
stage('Test2'){
steps {
script {
sh "docker run --rm --entrypoint '' -v \${AWS_CONFIG_FILE:-/home/ubuntu/.aws/config}:/root/.aws/config:ro -v \${AWS_SHARED_CREDENTIALS_FILE:-/home/ubuntu/.aws/credentials}:/root/.aws/credentials:ro -v ${WORKSPACE}/test-results:/srv/www/lib/test/html_reports docker exec -it ${IMAGE_NAME} bash -c 'cd test && ruby test2.rb'"
}
}
}
}
}
错误:docker exec\": executable file not found in $PATH":
Docker文件:
FROM ruby:2.5.3 as build
RUN apt-get update && \
apt-get install -qy \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN apt-key fingerprint 0EBFCD88
RUN add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
RUN apt-get update && \
apt-get install -qy \
docker-ce \
docker-ce-cli \
containerd.io \
build-essential \
libldap-dev \
libsasl2-dev \
libxml2-dev \
libxslt-dev \
libldap2-dev \
libsasl2-dev \
git \
jq
RUN curl -fsSL -o /usr/local/bin/aws-vault 'https://github.com/99designs/aws-vault/releases/download/v5.1.2/aws-vault-linux-amd64' && \
chmod 755 /usr/local/bin/aws-vault
RUN gem install bundler -v '2.0.2'
WORKDIR /tmp
COPY Gemfile* ./
RUN bundler install --without=development
FROM ruby:2.5.3-slim
RUN mkdir -p /srv/www/lib /srv/www/tmp/sockets /srv/www/tmp/pids
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /usr/local/bin/aws-vault /usr/local/bin/aws-vault
COPY --from=build /usr/bin/docker* /usr/bin/
COPY ops-cli2.rb /srv/www/lib/cli2.rb
ENV AWS_SHARED_CREDENTIALS_FILE=/root/.aws/credentials
WORKDIR /srv/www/lib
COPY . .
RUN ["chmod","+x","/srv/www/lib/cli2.rb"]
ENTRYPOINT ["/srv/www/lib/cli2.rb"]
解决方法
我认为您只需在命令行中删除docker exec -it
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。