Git script parameter pipeline

I am trying to get a parameterized pipe job in Jenkins (2.19.4) to work with the following specifications:

  • BRANCH_TO_BUILD parameter that retrieves all available branches from the gitlab repository for the user to select one
  • A Groovy Pipeline script that performs various steps that work great when used as a Jenkins file from SCM.

The error I am getting is related to the Git parameter:

 net.uaznia.lukanus.hudson.plugins.gitparameter.jobs.WorkflowJobWrapper getSCMFromDefinition SEVERE: Get repo scm from Workflow job fail java.lang.NoSuchMethodException: org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition.getScm() 

As far as I know, Jenkins cannot get the SCM configuration from the script pipeline before requesting parameter input.

I know there is a new JENKINS-39530 function request, but is there any other approach for this?

+5
source share
1 answer

From what I understand, you want to get a task in which the user selects a branch. Branches should be kept in sync with branches in GitLab.

One way to do this is through the DSL plugin .

  • Create a task, possibly called a task creator, that runs every X minutes or runs from GitLab.
  • Let job-creater complete the DSL build step.
  • DSL may ask GitLab with REST to get branches. Scroll through the branches to create pipelining.

The DSL task will look something like this:

 ... pipelineJob("the pipeline job") { parameters { def branches = ['[Choose]'] getJson(server+ "/rest/request/to/gitlab...") .values .each { branch -> if (branch.displayId.startsWith('feature')) { branches.push(branch.displayId) } } choiceParam( 'branch', branches, 'Pick a branch.') } ... 
+1
source

Source: https://habr.com/ru/post/1261946/


All Articles