我正在尝试从詹金斯管道构建图像:
stage("Build and Publish") {
steps {
withDockerRegistry(dockerCredentials) {
sh "pwd" // returns /var/lib/jenkins/workspace/my-project
sh "docker build -t='my-hub/my-project-indexer:${env.GIT_TAG}' indexer/"
sh "docker push my-hub/my-project-indexer:${env.GIT_TAG}"
sh "docker build -t='my-hub/my-project-web:${env.GIT_TAG}' web/"
sh "docker push my-hub/my-project-web:${env.GIT_TAG}"
}
}
}
Dockerfile
看起来像这样:
FROM openjdk:8
RUN mkdir /logs && chown 1:1 -R /logs
WORKDIR /
USER user
ADD target/scala-2.11/indexer.jar /app/indexer.jar
VOLUME /logs
CMD [ "java", "-jar", "/app/indexer.jar" ]
有趣的是,ADD
步骤失败,并显示以下消息-ADD failed: stat /opt/app/docker/tmp/docker-builder255975818/target/scala-2.11/indexer.jar: no such file or directory
。
当我显然位于项目根目录中时,我不知道为什么docker使用/opt/app/docker/tmp/docker-builder...
文件夹。我是Jenkins和Docker的新手,所以对可能出现的愚蠢问题提前致歉。