我正在远程代理节点上运行Jenkins管道作业,在该节点上,它会进行docker-compose来构建我的应用程序。运行管道时,它失败,但以下异常。 docker-compose已安装在远程节点上,并且对可执行文件具有完全权限。我也在管道中设置了PATH。有人可以帮我吗?
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Deploy to staging)
[Pipeline] echo
PATH is: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/bin
[Pipeline] sh
+ /usr/bin/docker-compose up --build -d
/var/jenkins_home/workspace/calc_multi@tmp/durable-060052a9/script.sh: 1: /var/jenkins_home/workspace/calc_multi@tmp/durable-060052a9/script.sh: /usr/bin/docker-compose: not found
[Pipeline] }
[Pipeline] // stage
我的管道中的代码段
pipeline {
environment {
registry = "sudheshpn/calculator"
registryCredential = 'dockerhub'
PATH = "$PATH:/usr/bin"
dockerImage = ''
}
stage("Deploy to staging") {
steps {
echo "PATH is: $PATH"
sh "/usr/bin/docker-compose up --build -d"
}
}
远程代理配置
root@ci-cd:/usr/bin# ls -ltr docker-compose
-rwxrwxrwx 1 root root 420 Apr 23 11:41 docker-compose
root@ci-cd:/usr/bin# pwd
/usr/bin
root@ci-cd:/usr/bin# docker-compose -v
docker-compose version 1.21.0, build unknown
正在从远程节点手动执行
root@ci-cd:/var/jenkins_home/workspace/calc_multi# /usr/bin/docker-compose up --build -d
Building calculator
Step 1/7 : FROM williamyeh/java8
---> 00bc163fa009
Step 2/7 : ADD build/libs/calculator-0.0.1-SNAPSHOT.jar app.jar
---> Using cache
---> 31096985299e
答案 0 :(得分:0)
我怀疑您需要在管道中定义远程代理节点标签,否则您应该在Jenkins主服务器本身上安装docker-compose
-
pipeline {
agent { label 'ci-cd' }
stages {}
}
答案 1 :(得分:0)
docker compose安装在远程节点上,但是您定义的代理是docker。 docker-compose是否安装在docker sudheshpn/calculator
上?
我个人不建议在管道中使用docker-compose。它是用于开发而非CI的工具。对于CI,我将单独使用docker或jenkins kubernetes插件一次部署容器吊舱