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

Jenkinsfile on change request is not consistent with console log

    XMLWordPrintable

Details

    Description

      At the top of the console log for a build running on a Gitlab merge request, I see output similar to the following:
      16:12:10 Querying the current revision of merge request #1...

      16:12:10 Current revision of merge request #1 is 30c945266d014280630074dafbe6ba31991adc90*

      16:12:11* Obtained Jenkinsfile from 56e3895c10f6163a93e025647e8e0dfcfa88ca9d+30c945266d014280630074dafbe6ba31991adc90

      i.e. it should be the Jenkinsfile as if the two commits identified are merged together.

      However, that does not seem to be the case - it seems that the Jenkinsfile it uses is that from the source branch head only (and this is how it looks if I examine the Jenkinsfile in Replay)

      I have replicated this using a simple test repository as follows:

      1) Create a new repo
      2) Commit the following Jenkinsfile to master:

      echo "one"
      

      3) Branch off master
      4) Add the following to Jenkinsfile on the branch:

      echo "two"
      

      5) Add the following to Jenkinsfile on master:

      echo "three"
      

      6) Raise a merge request

      When the build runs, it will echo one and two, but not three.

      I have conducted the same test against a Bitbucket branch source, and that seems to work correctly, which suggests the issue is with the plugin rather than Jenkins core.

       

       

       

      Attachments

        Activity

          mosaic_nick Nick Chadwick added a comment -

          Further investigation suggests that this is an issue with the lightweight checkout in the plugin. If I force heavyweight checkouts, it works as expected. And I suspect from my reading that I can use a reference repository as a better alternative workaround.

          mosaic_nick Nick Chadwick added a comment - Further investigation suggests that this is an issue with the lightweight checkout in the plugin. If I force heavyweight checkouts, it works as expected. And I suspect from my reading that I can use a reference repository as a better alternative workaround.
          dubrsl Viacheslav Dubrovskyi added a comment - - edited

          This is a really big problem for me. Can someone suggest a quick fix or workaround?

          mosaic_nick How did you disable lightweight checkouts? Thank you!

          dubrsl Viacheslav Dubrovskyi added a comment - - edited This is a really big problem for me. Can someone suggest a quick fix or workaround? mosaic_nick How did you disable lightweight checkouts? Thank you!
          mosaic_nick Nick Chadwick added a comment - - edited

          dubrsl you can disable lightweight checkouts only at a Jenkins-wide level, by setting 

          -Dorg.jenkinsci.plugins.workflow.multibranch.SCMBinder.USE_HEAVYWEIGHT_CHECKOUT=true

          in the command-line args used to start it up. Be aware that this will have an impact on build times, as the master will always need to check out the whole repo just to get the Jenkinsfile, but at least it will be at the right revision.

          I've actually forked the GitLab plugin and fixed it so lightweight checkout works. At some point, I'll try to get it PR'd.

          mosaic_nick Nick Chadwick added a comment - - edited dubrsl you can disable lightweight checkouts only at a Jenkins-wide level, by setting  -Dorg.jenkinsci.plugins.workflow.multibranch.SCMBinder.USE_HEAVYWEIGHT_CHECKOUT= true in the command-line args used to start it up. Be aware that this will have an impact on build times, as the master will always need to check out the whole repo just to get the Jenkinsfile, but at least it will be at the right revision. I've actually forked the GitLab plugin and fixed it so lightweight checkout works. At some point, I'll try to get it PR'd.

          mosaic_nick Thanks for the help. Yes, cloning the entire repository is expensive, but there are no other options.
          Please share the fix. I'm ready to install and test.
          I also have the fix, when it is not possible to remove the checkbox on "Enable triggers by Trusted Members only" and will prepare PR.

          dubrsl Viacheslav Dubrovskyi added a comment - mosaic_nick Thanks for the help. Yes, cloning the entire repository is expensive, but there are no other options. Please share the fix. I'm ready to install and test. I also have the fix, when it is not possible to remove the checkbox on "Enable triggers by Trusted Members only" and will prepare PR.

          We are also having this problem. Heavy weight checkout is not an option for us.

          mosaic_nick : have you created a PR, yet? Or is your fork with the fix available somewhere?

          gordin Christoph Vogtländer added a comment - We are also having this problem. Heavy weight checkout is not an option for us. mosaic_nick : have you created a PR, yet? Or is your fork with the fix available somewhere?
          gordin Christoph Vogtländer added a comment - Seems to be https://github.com/mosaic-nick/gitlab-branch-source-plugin/commit/f53af04b5eb64578a8f18bd2f77066eccdfdb8bd

          People

            baymac Parichay Barpanda
            mosaic_nick Nick Chadwick
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: