Reputation: 61
I'm trying to get a Parametrized Pipeline Job in Jenkins (2.19.4) to work with the following specs:
BRANCH_TO_BUILD
Git parameter that retrieves all available branches from a gitlab repository for the user to pick oneThe 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
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
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.
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