Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-67520

Cannot invoke docker-compose in multibranch-pipeline on merge event

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • None

      "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:

      1. Install and configure GitLab branch source in global jenkins settings (Manage Web Hooks=true, Manage System Hooks=true)
      2. Make sure docker-compose is installed on the agent (or wherever the pipeline is run).
      3. Create GitLab project with name debug-docker-compose and have the only content the Jenkinsfile pasted above.
      4. On jenkins setup a Multibranch Pipeline job with Branch source = "GitLab project". Behavior= "Discover branches: all branches".
      5. On Gitlab (via web IDE) add some dummy changes to the Jenkinsfile, and commit it to a feature branch.
      6. Ensure that the feature branch is triggered on Jenkins and it finishes with SUCCESS and docker-compose version is printed.
      7. Merge the feature branch.
      8. 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.

            baymac Parichay Barpanda
            tamas Tamas Mx
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: