docker-compose:找不到命令jenkins管道

时间:2018-08-28 07:28:31

标签: docker jenkins docker-compose jenkins-pipeline

当我试图在蓝海中启动这段代码https://github.com/Sabrjkee/docker-qrcode-generator.git时,我会重蹈覆辙

> [ker-qrcode-generator_master-RJ4RZWEFLU27HJ7Q4MAGBQFTT7E6MLQM6BRPZAHRAEYIU27NR5VA]
> Running shell script
> 
> + docker-compose --version
> 
> /var/lib/jenkins/workspace/ker-qrcode-generator_master-RJ4RZWEFLU27HJ7Q4MAGBQFTT7E6MLQM6BRPZAHRAEYIU27NR5VA@tmp/durable-4dbe9184/script.sh:
> line 2: docker-compose: command not found
> 
> script returned exit code 127

在控制台中

$ docker-compose --version
docker-compose version 1.17.0, build ac53b73
$ docker --version
Docker version 18.03.1-ce, build 3dfb8343b139d6342acfd9975d7f1068b5b1c3d3

1 个答案:

答案 0 :(得分:1)

Jenkins管道中的docker-compose中似乎没有包含PATH二进制文件的文件夹。

您可以使用environment部分添加它:

pipeline {

    environment {
        PATH = "$PATH:<folder_where_docker-compose_is>"
    }
}

例如,如果docker-compose位于:

$ which docker-compose
/usr/local/bin/docker-compose

Jenkinsfile将修改为:

pipeline {

    environment {
        PATH = "$PATH:/usr/local/bin"
    }
}