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

multibranchPipelineJob overrides old branch indexing sources

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: job-dsl-plugin
    • Labels:
      None
    • Environment:
      Debian 8
      Jenkins 2.46.1 (as service)

      Plugins (all newest stable):
      Job DSL 1.61
      Pipeline: Multibranch 2.14
    • Similar Issues:

      Description

      When running the multibranchPipelineJob step it seems like it overrides the sources of a Multibranch Pipeline Job instead of just updating it. After running the step, even though nothing has changed the output of the branch indexing will become:

      Checking branch master
            ‘Jenkinsfile’ found
      Met criteria
      Takeover for job-dsl-plugin_multibranch » master by source #1 from source that no longer exists
      Branch reopened: master (b409f3996299dd12244d6cf7f8b6d8df3aa674ca)
      Scheduled build for branch: master
      

       

      To test this, I have installed a brand new Jenkins with the Pipeline plugins and Job DSL plugin (all as the stable version) and made a freestyle job, with a Job DSL step that has the following script:

      multibranchPipelineJob('job-dsl-plugin_multibranch') {
        branchSources {
          git { 
            remote('https://github.com/jenkinsci/job-dsl-plugin.git')
          }
        }
      }
      

       

      After running the Job DSL step and afterwards running branch indexing a "master" job is created with the following log message from branch indexing:

      Checking branch master
            ‘Jenkinsfile’ found
      Met criteria
      Scheduled build for branch: master
      

       

      When running branch indexing again, following log message are shown as expected:

      Checking branch master
            ‘Jenkinsfile’ found
      Met criteria
      No changes detected: master (still at b409f3996299dd12244d6cf7f8b6d8df3aa674ca)
      

       

      However, if I run the Job DSL again and run branch indexing, the first log message (with takeover and so on) are shown. This is not what I would have expected, I would have expected something like a "no changes detected" message.

       

        Attachments

          Activity

          Hide
          widgetpl Mike Dziedziela added a comment - - edited

          I face the same issue.

          Jenkins - v2.60.1

          Job DSL - v1.64

          Pipeline Multibranch - v2.16

          I have just commited to test branch but scanning has triggered build for all branches which had Jenkinsfile in it.

          Checking branch develop
                ‘Jenkinsfile’ found
              Met criteria
          Takeover for example_project » develop by source #1 from source that no longer exists
          Branch reopened: develop (11617f79c6408e1d5fd54ea60a64d31b787a9471)
          Scheduled build for branch: develop
          
          Checking branch test
                ‘Jenkinsfile’ found
              Met criteria
          Takeover for example_project » test by source #1 from source that no longer exists
          Branch reopened: test (f84bcda107da005f9363759a68af2008a135a84e)
          Scheduled build for branch: test
          
          Checking branch master
                ‘Jenkinsfile’ found
              Met criteria
          Takeover for example_project » master by source #1 from source that no longer exists
          Branch reopened: master (2a2521fe4ea2ab71edb51b3279b5e49c4c8e77d5)
          Scheduled build for branch: master

          let me know if you need more information.

          EDIT:

          Jenkins is integrated with GitLab v. 10.0.3 CE

          Show
          widgetpl Mike Dziedziela added a comment - - edited I face the same issue. Jenkins - v2.60.1 Job DSL - v1.64 Pipeline Multibranch - v2.16 I have just commited to test branch but scanning has triggered build for all branches which had Jenkinsfile in it. Checking branch develop ‘Jenkinsfile’ found Met criteria Takeover for example_project » develop by source #1 from source that no longer exists Branch reopened: develop (11617f79c6408e1d5fd54ea60a64d31b787a9471) Scheduled build for branch: develop Checking branch test ‘Jenkinsfile’ found Met criteria Takeover for example_project » test by source #1 from source that no longer exists Branch reopened: test (f84bcda107da005f9363759a68af2008a135a84e) Scheduled build for branch: test Checking branch master ‘Jenkinsfile’ found Met criteria Takeover for example_project » master by source #1 from source that no longer exists Branch reopened: master (2a2521fe4ea2ab71edb51b3279b5e49c4c8e77d5) Scheduled build for branch: master let me know if you need more information. EDIT: Jenkins is integrated with GitLab v. 10.0.3 CE
          Hide
          kizzie Kat added a comment -

          So the changes made to fix this one seem to still use a random UUID - I'm not sure whether or not generating it based off the name or the repo being cloned (or why not both) would fix this - If I'm reading the problem correctly you need a static UUID being generated for the job for it to be able to cope  - https://github.com/jenkinsci/job-dsl-plugin/compare/c722b8bb538c...f8b51912215c#diff-f468c06e75a4e86856c95107995aaa0fR6

          (and yes I'm also still getting this issue, and have been wondering what is causing it for a while - going to try setting the id manually for a bit instead)

          Show
          kizzie Kat added a comment - So the changes made to fix this one seem to still use a random UUID - I'm not sure whether or not generating it based off the name or the repo being cloned (or why not both) would fix this - If I'm reading the problem correctly you need a static UUID being generated for the job for it to be able to cope  - https://github.com/jenkinsci/job-dsl-plugin/compare/c722b8bb538c...f8b51912215c#diff-f468c06e75a4e86856c95107995aaa0fR6 (and yes I'm also still getting this issue, and have been wondering what is causing it for a while - going to try setting the id manually for a bit instead)
          Hide
          duemir Denys Digtiar added a comment -

          I have created a fresh environment from 2.121 and installing:

          • Pipeline: Multibranch 2.18
          • Github Branch Source Plugin 2.3.4
          • Job DSL 1.69

          I was able to reproduce the issue using the steps in the description. I can still see

          Takeover for job-dsl-plugin_multibranch » master by source #1 from source that no longer exists
          Branch reopened: master (5045094d82daa475fe79e7f5e52eba58c6df9020)
          Scheduled build for branch: master
          

          after I re-run the Seed Job.

          Show
          duemir Denys Digtiar added a comment - I have created a fresh environment from 2.121 and installing: Pipeline: Multibranch 2.18 Github Branch Source Plugin 2.3.4 Job DSL 1.69 I was able to reproduce the issue using the steps in the description. I can still see Takeover for job-dsl-plugin_multibranch » master by source #1 from source that no longer exists Branch reopened: master (5045094d82daa475fe79e7f5e52eba58c6df9020) Scheduled build for branch: master after I re-run the Seed Job.
          Hide
          duemir Denys Digtiar added a comment - - edited

          Sorry, Daniel Spilker . It looks like I misunderstood the resolution. Is the resolution to manually add unique Ids to the source definitions? Like this:

          multibranchPipelineJob('job-dsl-plugin_multibranch') {
            branchSources {
              def repo = 'https://github.com/jenkinsci/job-dsl-plugin.git'
              git {
                id = UUID.nameUUIDFromBytes(repo.getBytes())
                remote(repo)
              }
            }
          }
          Show
          duemir Denys Digtiar added a comment - - edited Sorry, Daniel Spilker . It looks like I misunderstood the resolution. Is the resolution to manually add unique Ids to the source definitions? Like this: multibranchPipelineJob( 'job-dsl-plugin_multibranch' ) { branchSources { def repo = 'https: //github.com/jenkinsci/job-dsl-plugin.git' git { id = UUID.nameUUIDFromBytes(repo.getBytes()) remote(repo) } } }
          Hide
          widgetpl Mike Dziedziela added a comment -

          Denys Digtiar yes, it worked for me and I use repository name for id.

          Show
          widgetpl Mike Dziedziela added a comment - Denys Digtiar yes, it worked for me and I use repository name for id.

            People

            • Assignee:
              daspilker Daniel Spilker
              Reporter:
              anigif Anders Kielsholm
            • Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: