I am having a JJB kind of pipeline. In that i would like to have an input step being appended (Yes/No option for confirmation of build) .So when i tried to append the input step(as mentioned below) inside groovy script it throws error.
def userInput = input(
id: ‘userInput’,
message: ‘Do you approve the build?’,
parameters: [choice(name: ‘APPROVAL’, choices: [‘Yes’, ‘No’])]
)
Error msg:
Caught: groovy.lang.MissingMethodException: No signature of method: hudson48964004661590194.choice() is applicable for argument types: (LinkedHashMap) values: [[name:APPROVAL, choices:[Yes, No]]] 13:15:20 Possible solutions: collect() 13:15:20 groovy.lang.MissingMethodException: No signature of method: hudson48964004661590194.choice() is applicable for argument types: (LinkedHashMap) values: [[name:APPROVAL, choices:[Yes, No]]] 13:15:20 Possible solutions: collect() 13:15:20 at hudson48964004661590194.run(hudson48964004661590194.groovy:11) 13:15:20 Build step ‘Execute Groovy script’ marked build as failure
Seems you’re using a freestyle job with an Execute groovy script step. But you try to use something that is meant for pipeline jobs. So this can’t work.
Hi @mawinter69 i can sense that now .But in other way lets say i have a freestlye pipeline with a lot a input parameter with string,choice,active choice paramater etc. I want to pass this parameter from freestlye job to the another job which has the same input parameter.
How can i acheive that?
Is that all have to pass as like below manually by fetch all param values to another pipeline?
build job: ‘main_job’, parameters: [[$class: ‘StringParameterValue’, name: ‘Type’, value: Type],
[$class: ‘StringParameterValue’, name: ‘VERSION’, value: VERSION ]]
Also please let me know how can i pass for choice and extended choice paramater to the other build?
again you try to use something that is only available to pipeline jobs.
you can’t do this with groovy in a freestyle job. Freestyle jobs are not pipelines and have limited capabilities.
In order to call other jobs with parameters from freestyle jobs you need the plugin Parameterized Trigger. This allows you to run a build step that will trigger the job and you can forward all parameters.
I would recommend to switch from freestyle to real pipelines as this allows you to programmatically define you workflow and you can make use of the snippets you now posted.