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

"Calculate changelog against a specific branch" doesn't appear in configuration

XMLWordPrintable

      I have a typical Multibranch Pipeline using the GitHub branch source.

      I have a "main" branch. When people want to do a change they do it in a branch, which can later be merged into main. I use the discoverGitReferenceBuild step from the Git Forensics Plugin to specify all the other branches should use "main" as reference. But the "changes" list in the branch:

      • Is always empty in the first job
      • Is relative to the previous branch job for other jobs

      The git plugin has the "Calculate changelog against a specific branch" option (https://github.com/jenkinsci/git-plugin#calculate-changelog-against-a-specific-branch). But I can't set it from the Multibranch Pipeline project configuration, it's just not there in the list of options.

      You could say this is a github-branch-source plugin issue. But the option doesn't appear if I use just "git" as a branch source either (it's there if I use "Single repository & branch"), so I suspect the issue is in the git plugin.

       

      This basic workflow can actually be supported, but it's strangely complicated to. I have had to:

      • Explicitly specify the main branch in "Specify ref specs", since otherwise the clone didn't have the branch to "Calculate against".
      • Change a simple (possibly implicit) 
        checkout scm

        for 

        def get_gitscm_extensions_list() {
          if(env.BRANCH_NAME == 'main') {
            return scm.extensions
          }
        
          return scm.extensions + [changelogToBranch(changelogBase(compareRemote: 'origin', compareTarget: 'main'))]
        }
        
        ....
        
        checkout scmGit(branches: scm.branches, extensions: get_gitscm_extensions_list(), userRemoteConfigs: scm.userRemoteConfigs)

      Specifically, the lack of the change list in the first job of a branch, which people want to use for example to find the user to send notifications to or to decide whether the job should be built makes people unable to find the above solution do weird things. See, for example, the explanation about the "currentBuild.previousCompletedBuild != null" trick in https://stackoverflow.com/questions/60084946/jenkins-git-changelog-on-first-build

       

      I am also wondering why I do even need a discoverGitReferenceBuild step. I really want the change list to match the reference build, so it would make sense for both things to be calculated by the same plugin. Shouldn't the git plugin set the reference build when it finds it when looking for it to create the changes list?

            Unassigned Unassigned
            reddwarf94 Cristian
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: