xOUe
xOUe

Reputation: 61

Git parameter pipeline script

I'm trying to get a Parametrized Pipeline Job in Jenkins (2.19.4) to work with the following specs:

The error I'm getting is related to 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 is not capable of retrieving the SCM configuration from pipeline script before asking for parameter's input.

I know there is a new feature request JENKINS-39530 but is there a different approach to accomplish this?

Upvotes: 5

Views: 4163

Answers (2)

idriss Eliguene
idriss Eliguene

Reputation: 897

For me I use the Input stage to interact with the user pipeline running. The pipeline is self don't have paramets but at running you have an input that ask user branh they want to build You start pipeline by checking out the git projet, afther you use the worksopace to generate with awk the list of branch on a signe file, and then you user this file to build the choice off the input. you can see the example at this link: enter link description here

Upvotes: 0

Tomas Bjerre
Tomas Bjerre

Reputation: 3520

From what I understand you want a job where the user selects a branch. The branches should be kept in sync with the branches in GitLab.

One way to do that is with the Job DSL plugin.

  1. Create a job, perhaps called job-creator, that runs every X minutes, or is triggered from GitLab.
  2. Let job-creator run a DSL build step.
  3. The DSL may ask GitLab with REST to get the branches. Loop through the branches to create the pipeline-job.

The job DSL would look similar to 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.')
  }
...

Upvotes: 1

Related Questions