我有一个非常简单的Jenkins文件,如下所示。
NgModule
我已经完全按预期工作了(例如:按预期安装卷,移动图片,拉动图像,实际运行def workspace
node {
workspace = sh(returnStdout: true, script: 'pwd').trim()
}
pipeline {
agent none
stages {
stage('Back-end') {
agent {
docker {
image 'composer'
args "-v /var/lib/jenkins/.composer/auth.json:/.composer/auth.json -v $workspace:/app"
}
}
steps {
sh 'php -v'
sh 'composer install --no-interaction --working-dir=$WORKSPACE/backend'
}
}
}
}
),只有一个小例外...... < / p>
紧随composer install
进入shell步骤后,运行docker run
并在1秒后死亡,然后立即进入sh 'composer install...'
和docker stop --time 1 ...
步骤。< / p>
我不知道这是来自Composer做的奇怪事情,还是有一些可配置的超时我完全不知道。
以前有人处理过这个吗?
编辑:
以下是更多信息:
docker rm ...
以及之前的工作
[Pipeline] withDockerContainer
Jenkins does not seem to be running inside a container
$ docker run -t -d -u 997:995 -v /var/lib/jenkins/.composer/auth.json:/.composer/auth.json -v [...] -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** --entrypoint cat composer
[Pipeline] {
[Pipeline] sh
[workspace] Running shell script
+ php -v
PHP 7.1.9 (cli) (built: Sep 15 2017 00:07:01) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
[Pipeline] sh
[workspace] Running shell script
+ composer install --no-interaction --working-dir=/app/backend --no-progress --no-ansi
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 29 installs, 0 updates, 0 removals
- Installing laravel/tinker (v1.0.2): Downloading[Pipeline] }
$ docker stop --time=1 ee693aaa7cdde41b714fdc91dbc1b05ac07fe2be7904ab1ed528fb0a3f771047
$ docker rm -f ee693aaa7cdde41b714fdc91dbc1b05ac07fe2be7904ab1ed528fb0a3f771047
[Pipeline] // withDockerContainer
[Pipeline] }
它的工作原理可以看出,但最后的返回代码是......
Installing dependencies (including require-dev) from lock file
Package operations: 55 installs, 0 updates, 0 removals
- Installing symfony/finder (v3.3.6): Downloading (connecting...)[Pipeline] }
编辑2:
让这个工作变得更简单,请参阅要点以获取更多信息:
https://gist.github.com/chuckyz/6b78b19a6a5ea418afa16cc58020096e
答案 0 :(得分:0)
这是詹金斯的一个错误,所以在标记为已修复之前,我只是手动使用带有docker run ...
的sh步骤。
https://issues.jenkins-ci.org/browse/JENKINS-35370
e.g:
sh 'docker run -v $WORKSPACE:/app composer install'
答案 1 :(得分:0)