-
Type:
Bug
-
Resolution: Not A Defect
-
Priority:
Major
-
Component/s: gitlab-branch-source-plugin
-
None
-
Environment:Jenkins: 2.319.1 (runs as docker image jenkins/jenkins:2.319.1-jdk11) (today the latest LTS)
Jenkins master OS: Docker image is based on "Debian GNU/Linux 11 (bullseye)"
Jenkins agent OS: CentOS Linux 7 (Core)
GitLab Branch Source Plugin: 1.5.9 (today the latest version)
docker-compose: 1.29.2 (today the latest version)
docker: 20.10.7, build f0df350. (Today's latest is 20.10.11)Jenkins: 2.319.1 (runs as docker image jenkins/jenkins:2.319.1-jdk11) (today the latest LTS) Jenkins master OS: Docker image is based on "Debian GNU/Linux 11 (bullseye)" Jenkins agent OS: CentOS Linux 7 (Core) GitLab Branch Source Plugin: 1.5.9 (today the latest version) docker-compose: 1.29.2 (today the latest version) docker: 20.10.7, build f0df350. (Today's latest is 20.10.11)
"docker-compose -v" cannot be invoked in a Multibranch pipeline if the build was triggered via merge event. It seems as if the shell-command was somehow wrongly interpreted. Log:
16:07:16 Push event to branch master
16:07:16 Started by GitLab push by John Doe
16:07:16 Querying the current revision of branch master...
16:07:16 Current revision of branch master is xxxx
16:07:16 Obtained jenkins.groovy from abc123
16:07:16 [Pipeline] Start of Pipeline
16:07:16 [Pipeline] node
16:07:16 Running on xxx in /path/to/workspace
16:07:16 [Pipeline] {
16:07:16 [Pipeline] stage
16:07:16 [Pipeline] { (Declarative: Checkout SCM)
16:07:16 [Pipeline] checkout
16:07:16 Selected Git installation does not exist. Using Default
16:07:16 The recommended git tool is: NONE
16:07:16 using credential ssh-key-jenkins
16:07:16 Fetching changes from the remote Git repository
16:07:17 Cleaning workspace
16:07:17 Pruning obsolete local branches
16:07:17 Pruning obsolete local tags that do not exist on remotes
16:07:17 Fetching without tags
16:07:17 Checking out Revision xxx (master)
16:07:17 Commit message: "Merge branch 'NO-TICKET-tstchng' into 'master'"
16:07:16 > git rev-parse --resolve-git-dir /path/to/workspace/.git # timeout=10
16:07:16 > git config remote.origin.url git@xxxx:xxxx/debug-docker-compose.git # timeout=10
16:07:17 > git rev-parse --verify HEAD # timeout=10
16:07:17 Resetting working tree
16:07:17 > git reset --hard # timeout=10
16:07:17 > git clean -fdx # timeout=10
16:07:17 > git show-ref --tags -d # timeout=10
16:07:17 Fetching upstream changes from git@xxxx:xxxx/debug-docker-compose.git
16:07:17 > git --version # timeout=10
16:07:17 > git --version # 'git version 2.24.4'
16:07:17 using GIT_SSH to set credentials xxx
16:07:17 [INFO] Currently running in a labeled security context
16:07:17 [INFO] Currently SELinux is 'enforcing' on the host
16:07:17 > /usr/bin/chcon --type=ssh_home_t /data/home/jenkins/agent1/workspace/vops_debug-docker-compose_master@tmp/jenkins-gitclient-ssh12043561275246262173.key
16:07:17 > git fetch --no-tags --force --progress --prune -- git@xxxx.git +refs/heads/master:refs/remotes/origin/master # timeout=10
16:07:17 > git config core.sparsecheckout # timeout=10
16:07:17 > git checkout -f abc123# timeout=10
16:07:17 > git rev-list --no-walk b30bb1843a97f44482fbb3df22e86898ba924d06 # timeout=10
16:07:17 Selected Git installation does not exist. Using Default
16:07:17 The recommended git tool is: NONE
16:07:17 using credential ssh-key-jenkins
16:07:17 Selected Git installation does not exist. Using Default
16:07:17 The recommended git tool is: NONE
16:07:17 using credential ssh-key-jenkins
16:07:17 [GitCheckoutListener] Recording commits of 'git git@xxxx.git'
16:07:17 [GitCheckoutListener] Found previous build 'team-xxx/debug-docker-compose/master #16' that contains recorded Git commits
16:07:17 [GitCheckoutListener] -> Starting recording of new commits since 'b30bb18'
16:07:17 [GitCheckoutListener] -> Using head commit 'abc123' as starting point
16:07:17 [GitCheckoutListener] -> Git commit decorator successfully obtained 'io.jenkins.plugins.gitlabbranchsource.helpers.GitLabBrowser@55a1211c' to render commit links
16:07:17 [GitCheckoutListener] -> Recorded 2 new commits
16:07:17 [Pipeline] }
16:07:17 [Pipeline] // stage
16:07:17 [Pipeline] withEnv
16:07:17 [Pipeline] {
16:07:17 [Pipeline] stage
16:07:17 [Pipeline] { (Test)
16:07:17 [Pipeline] sh
16:07:17 + docker-compose -v
16:07:17 docker: invalid reference format: repository name must be lowercase.
16:07:17 See 'docker run --help'.
16:07:18 [Pipeline] }
16:07:18 [Pipeline] // stage
16:07:18 [Pipeline] }
16:07:18 [Pipeline] // withEnv
16:07:18 [Pipeline] }
16:07:18 [Pipeline] // node
16:07:18 [Pipeline] End of Pipeline
16:07:18 ERROR: script returned exit code 125
16:07:18 Finished: FAILURE
If the build is triggered manually ("Build now" button) or cron trigger then there is no error, eg. docker-compose version is printed out.
Also if the branch is merged but plain "git" is used as scm source (instead of gitlab-branch-source) then there is no error.
Jenkinsfile:
pipeline {
agent { label 'docker' }
stages {
stage('Test') {
steps {
sh "docker-compose -v"
}
}
}
}
Â
Steps to reproduce:
- Install and configure GitLab branch source in global jenkins settings (Manage Web Hooks=true, Manage System Hooks=true)
- Make sure docker-compose is installed on the agent (or wherever the pipeline is run).
- Create GitLab project with name debug-docker-compose and have the only content the Jenkinsfile pasted above.
- On jenkins setup a Multibranch Pipeline job with Branch source = "GitLab project". Behavior= "Discover branches: all branches".
- On Gitlab (via web IDE) add some dummy changes to the Jenkinsfile, and commit it to a feature branch.
- Ensure that the feature branch is triggered on Jenkins and it finishes with SUCCESS and docker-compose version is printed.
- Merge the feature branch.
- Expected behavior: On jenkins master branch also prints the docker-compose version. Actual behavior: docker: invalid reference format: repository name must be lowercase.
Note: the same behavior happens if the jenkins project is an "Organizational Folder" with Branch source = "GitLab group".
After reproducing the bug if I retry the build with "Build now" the pipeline runs without error.