jenkinsci / gitlab-branch-source-plugin

A Jenkins Plugin for GitLab Multibranch Pipeline jobs and Folder Organization
https://plugins.jenkins.io/gitlab-branch-source
MIT License
121 stars 87 forks source link

configure using groovy #275

Open apallares19 opened 1 year ago

apallares19 commented 1 year ago

Describe your use-case which is not covered by existing documentation.

Hello, can someone tell me how to configure this feature using groovy file?

branchSources { branchSource { source { gitlab { // Select the GitLab Server where you want the projects to be discovered from. serverName('default') // Specify the namespace which owns your projects. projectOwner('gitlab-group') // Select the project on which you want to perform the Multibranch Pipeline Job. projectPath('gitlab_group/REPO_NAME') // Checkout credentials is only needed for private projects. credentialsId('gitlab') id('gitlab_group/REPO_NAME') //projectId(long value). ----> what is this value for????? traits { // gitLabBranchDiscovery{ // strategyId(1) // } } } } } }

I'm currently using the feature through jenkins ui but i could'nt configure it using jenkins groovy.

Reference any relevant documentation, other materials or issues/pull requests that can be used for inspiration.

No response

Turiok commented 1 year ago

Hi @apallares19 ,

Thank you for thinking of putting the code in markdown tags so that it is more readable for us.

the projectId is the Id of your Gitlab project. You can see it in the Gitlab IHM : image

I don't have job DSL in my Jenkins. But If you can propose a complete working example in the README, that would be cool.

Describe your use-case which is not covered by existing documentation.

Hello, can someone tell me how to configure this feature using groovy file?

branchSources { 
 branchSource { 
   source { 
     gitlab { 
       // Select the GitLab Server where you want the projects to be discovered from. 
       serverName('default') 
       // Specify the namespace which owns your projects. 
       projectOwner('gitlab-group') 
       // Select the project on which you want to perform the Multibranch Pipeline Job. 
       projectPath('gitlab_group/REPO_NAME') 
       // Checkout credentials is only needed for private projects. 
       credentialsId('gitlab') 
       id('gitlab_group/REPO_NAME') 
       //projectId(long value). ----> what is this value for????? 
       traits { 
         // gitLabBranchDiscovery{ 
           // strategyId(1) 
         // }
       } 
     }
   }
 }
}

I'm currently using the feature through jenkins ui but i could'nt configure it using jenkins groovy.

Reference any relevant documentation, other materials or issues/pull requests that can be used for inspiration.

No response