-
Bug
-
Resolution: Fixed
-
Major
-
None
-
jenkins: 2.204.1
gitlab-branch-source: 1.4.3
job-dsl: 1.76
templating-engine: 1.5.1
Issue description
*Use case*: Gitlab-branch-source Organization Folder + [Jenkins Templating Engine](https://github.com/jenkinsci/templating-engine-plugin)
Let say I have a Merge Request (MR) from branch A to branch B. Both branches have pipeline_config.groovy in root directory. But when the MR triggers Jenkins build, templating engine doesn't obtain pipeline_config.groovy of any branch, it only obtains pipeline_config.groovy in Governance repo
If the build is triggered by branch commit, then templating engine works fine (obtain pipeline_config.groovy in both source repo and Governance repo)
Steps to reproduce the issue
1. Governance's pipeline_config.groovy
// restrict individual repository Jenkinsfiles allow_scm_jenkinsfile = false // skip the default JTE checkout and do it explicitly skip_default_checkout = truelibraries{ merge = true gitlab sonarqube }
2. Source repo's pipeline_config.groovy
libraries{
kubernetes {
podTemplate = "nodeTemplate"
}
npm
}
3. Pipeline template (Jenkinsfile in Governance repo)
startPod { clone_source() build() static_code_analysis() }
4. JCasc job config
jobs: - script: > organizationFolder('Gitlab Organization Folder') { description("Gitlab folder configured with JCasC") displayName('Projects') // "Projects" organizations { gitLabSCMNavigator { projectOwner("owner_id") credentialsId("ssh_key") serverName("gitlab-server") // "Traits" ("Behaviours" in the GUI) that are "declarative-compatible" traits { subGroupProjectDiscoveryTrait() // discover projects inside subgroups gitLabBranchDiscovery { strategyId(3) // discover all branches } originMergeRequestDiscoveryTrait { strategyId(1) // discover MRs } gitLabTagDiscovery() // discover tags } } } // "Traits" ("Behaviours" in the GUI) that are NOT "declarative-compatible" // For some 'traits, we need to configure this stuff by hand until JobDSL handles it // https://issues.jenkins.io/browse/JENKINS-45504 configure { node -> def traits = node / navigators / 'io.jenkins.plugins.gitlabbranchsource.GitLabSCMNavigator' / traits traits << 'io.jenkins.plugins.gitlabbranchsource.ForkMergeRequestDiscoveryTrait' { strategyId('2') trust(class: 'io.jenkins.plugins.gitlabbranchsource.ForkMergeRequestDiscoveryTrait$TrustPermission') } //traits << 'io.jenkins.plugins.gitlabbranchsource.SSHCheckoutTrait' { // credentialsId('ssh_key') //} } // "Project Recognizers" projectFactories { templateMultiBranchProjectFactory() } // "Orphaned Item Strategy" orphanedItemStrategy { discardOldItems { daysToKeep(-1) numToKeep(-1) } } // "Scan Organization Folder Triggers" : 1 day // We need to configure this stuff by hand because JobDSL only allow 'periodic(int min)' for now configure { node -> node / triggers / 'com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger' { spec('H H * * *') interval(86400000) } } }
5. Trigger Jenkins build by Merge Request creation
What's the expected result?
- Templating engine obtains and merges pipeline_config.groovy in both source repo and Governance repo
What's the actual result?
- Templating engine doesn't obtain pipeline_config.groovy in source repo, it only obtains pipeline_config.groovy in Governance repo.
- This lead to build fail with error: No such DSL method startPod