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?
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.')
}
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With