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

Jenkinsfile on change request is not consistent with console log

    XMLWordPrintable

    Details

    • Similar Issues:

      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

          Hide
          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.

          Show
          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.
          Hide
          dubrsl Viacheslav Dubrovskyi added a comment - - edited

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

          Nick Chadwick How did you disable lightweight checkouts? Thank you!

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

          Viacheslav Dubrovskyi 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.

          Show
          mosaic_nick Nick Chadwick added a comment - - edited Viacheslav Dubrovskyi 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.
          Hide
          dubrsl Viacheslav Dubrovskyi added a comment -

          Nick Chadwick 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.

          Show
          dubrsl Viacheslav Dubrovskyi added a comment - Nick Chadwick 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.

            People

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

              Dates

              Created:
              Updated: