我正在尝试使用称为Kaniko的Jenkins共享库来构建容器。 Jenkins是在Kubernetes集群上运行的CloudBees Core。
我更喜欢尝试使用Pod模板来构建容器,但是如果需要的话,我可以使用专用的VM(但是我的客户不会满意)。
问题:从简单的Jenkinsfile
管道运行Kaniko可以正常工作,但是尝试从shared-library
运行它时出现错误。
我的共享库的片段:
docker.image('kaniko').inside('-u root --privileged') {
sh '''#!/busybox/sh
/kaniko/executor --context `pwd` --destination docker.artifactory.company.com/docker-local/hello-kaniko:latest
'''
}
我得到的错误(提示):
.
.
.
Building: default
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] sh
+ docker inspect -f . kaniko
/home/jenkins/workspace/cloud-services@tmp/durable-28d8debd/script.sh: line 1: docker: not found
[Pipeline] sh
+ docker pull kaniko
/home/jenkins/workspace/cloud-services@tmp/durable-dc065568/script.sh: line 1: docker: not found
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 127
Finished: FAILURE
还有其他人能够从Kubernetes上Jenkins的共享库中运行Kaniko吗?
最佳答案
我在kaniko容器中遇到了类似的问题,我要做的就是将PATH添加到环境中:
withEnv(['PATH+EXTRA=/busybox:/kaniko']) {
sh '''#!/busybox/sh
/kaniko/executor (....)
}
关于kubernetes - 使用Kaniko从Kubernetes CloudBees Jenkins共享库构建容器时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56078521/