[JIRA] (JENKINS-60915) Gitlab-branch-source Merge Request build failed with Templating Engine

14 views
Skip to first unread message

tritruong.tr@gmail.com (JIRA)

unread,
Jan 30, 2020, 2:43:03 AM1/30/20
to jenkinsc...@googlegroups.com
Tri Truong created an issue
 
Jenkins / Bug JENKINS-60915
Gitlab-branch-source Merge Request build failed with Templating Engine
Issue Type: Bug Bug
Assignee: Parichay Barpanda
Components: gitlab-branch-source-plugin
Created: 2020-01-30 07:42
Environment: jenkins: 2.204.1
gitlab-branch-source: 1.4.3
job-dsl: 1.76
templating-engine: 1.5.1
Priority: Major Major
Reporter: Tri Truong
        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)

        1. 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 = true

libraries

{ 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
    Unknown macro: { 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

    Unknown macro: { 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

    Unknown macro: { 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

    Unknown macro: { node -> node / triggers / 'com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger' { spec('H H * * *') interval(86400000) } }

    }
    ```

*5. Trigger Jenkins build by Merge Request creation*

        1. What's the expected result?
  • Templating engine obtains and merges pipeline_config.groovy in both source repo and Governance repo
        1. 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
    ```

*6. Tool version*
jenkins: 2.204.1
gitlab-branch-source: 1.4.3
job-dsl: 1.76
templating-engine: 1.5.1

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

tritruong.tr@gmail.com (JIRA)

unread,
Jan 30, 2020, 2:48:03 AM1/30/20
to jenkinsc...@googlegroups.com
Tri Truong updated an issue

Update code format

Change By: Tri Truong
#### 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* *
``` {code:java}
// restrict individual repository Jenkinsfiles
allow_scm_jenkinsfile = false
// skip the default JTE checkout and do it explicitly
skip_default_checkout =
true

libraries
truelibraries {

merge = true
gitlab
sonarqube
}
``` {code}
 

 

* * 2. Source repo's pipeline_config.groovy* *
``` {code:java}
libraries{
kubernetes {
podTemplate = "nodeTemplate"
}
npm
}
``` {code}
 

* * 3. Pipeline template (Jenkinsfile in Governance repo)* *
```
 
{code:java}
startPod {
clone_source()
build()
static_code_analysis()
}
``` {code}
 

* * 4. JCasc job config* *
```
 
{code:java}
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)
}
}
} {code}
```  

*
* 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

```

**6. Tool version**

jenkins: 2.204.1
gitlab-branch-source: 1.4.3
job-dsl: 1.76
templating-engine: 1.5.1

tritruong.tr@gmail.com (JIRA)

unread,
Jan 30, 2020, 2:52:02 AM1/30/20
to jenkinsc...@googlegroups.com

steventerrana@gmail.com (JIRA)

unread,
Jan 30, 2020, 6:10:02 PM1/30/20
to jenkinsc...@googlegroups.com

Hello, I maintain the Templating Engine Plugin (JTE). 

Some context here:  JTE fetches files from remote SCM's during initialization by leveraging the SCM API 2.0 spec to create an SCMFileSystem.  It seems as if the gitlab-branch-source plugin does not strictly adhere to the SCM API 2.0 spec. 

josephp90@gmail.com (JIRA)

unread,
Feb 7, 2020, 12:56:03 PM2/7/20
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages