-
Bug
-
Resolution: Unresolved
-
Minor
-
None
The changelog is not reflecting properly.
In my second stage I'm doing checkout and I'm using the ChangelogToBranch extension to record the change. But its not reflecting on the change tab.
I have total 4 repositories, and I'm checking out all the four repositories to record any changes.
In the below code I'm passing withChangelog = true
void checkoutBranch(List<String> branchNames, String repository, String targetDir = '', Boolean withChangelog = false) { def checkoutInfo = resolveScm( source: [$class : 'GitSCMSource', credentialsId: 'github-jenkins', id: '_', remote : "xyz.git", traits : [[$class: 'CleanAfterCheckoutTrait'], [$class: 'CleanBeforeCheckoutTrait'], [$class: 'GitLFSPullTrait'], [$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait'], headWildcardFilter(includes: branchNames.join(' '))]], targets: branchNames ) checkoutRevision(checkoutInfo.getBranches().get(0).getName(), repository, targetDir, withChangelog) } def checkoutRevision(String revision, String repository, String targetDir = '', Boolean withChangelog = false) { def extensions = [[$class: 'CleanCheckout'], [$class: 'CleanBeforeCheckout'], [$class: 'CloneOption', reference: referenceRepository(repository), honorRefspec: true, noTags: true], [$class: 'GitLFSPull']] if (withChangelog) { extensions << [$class: 'ChangelogToBranch', options: [compareRemote: 'origin', compareTarget: env.BRANCH_NAME]] } dir(targetDir) { def checkoutResult = checkout changelog: true, poll: false, scm: [$class : 'GitSCM', branches : [[name: revision]], browser : [$class: 'GithubWeb', repoUrl: "http://github.com/xyz/${repository}"], doGenerateSubmoduleConfigurations: false, extensions : extensions, submoduleCfg : [], userRemoteConfigs : [[credentialsId: 'github-jenkins', url: "xyz.git"]]] sshagent(['github-jenkins']) { command 'git -c lfs.concurrenttransfers=50 lfs pull', label: 'Ensure git lfs objects are present' } return checkoutResult } }
Attaching the screenshots for reference
Jenkins Version : 2.263.1
Git Plugin Version: 4.6.0
I'm unable to duplicate the problem you're seeing with my test case. My test case defines a branch named "JENKINS-66054" and another branch named "JENKINS-66054-older". The "JENKINS-66054" receives commits and the "JENKINS-66054-older" branch receives the same commits minus the most recent commit. That means that most of the time, "JENKINS-66054-older" is one commit behind "JENKINS-66054".
The Jenkinsfile for my test job uses the currentBuild.changeSets to read the changelog and raises an error if more or less than one change is reported in the job.
I think the issue you are seeing may be due to your definition of the branch to compare. You've defined it as env.BRANCH_NAME from the origin repository. As far as I understand it, env.BRANCH_NAME is the name of the branch that the Pipeline job is using. origin/env.BRANCH_NAME is the remote branch that represents the same branch that is checked out in the workspace. Since the checkout just happened, I would expect no differences between the local branch and origin/env.BRANCH_NAME.
Can you confirm that I've understood your Pipeline correctly?