Reputation: 103
I am attempting to pass parameters that are defined in a Jenkins configuration to a declarative pipeline. When I do this with the built in string, everything works fine:
string(name: 'rv', defaultValue: 'none', description: 'the release version')
Since these value should not be edited by the user in the Build with Parameters screen, I switched to using the hidden parameter plugin:
hidden(name: 'rv', defaultValue: 'none', description: 'the release version')
But this gives me an error when the pipeline script is run:
WorkflowScript: 30: Invalid parameter type "hidden". Valid parameter types: [booleanParam, buildSelector, choice, credentials, file, gitParameter, text, password, run, string]
Is there a method by which I can use the hidden parameter in a declarative Jenkins pipeline?
Upvotes: 9
Views: 6199
Reputation: 11
properties([[$class: 'ParametersDefinitionProperty',
parameterDefinitions: [
[$class: 'WHideParameterDefinition', name: 'isValid', defaultValue: 'false']
]
]])
I found my answer here: https://copyprogramming.com/howto/jenkins-hidden-parameters
Upvotes: 1
Reputation: 176
I was having the same issue and by coincidence I found the solution.
Supposing, that you have the already mentioned 'Hidden Param Plugin', add the following line to your Jenkinsfile in the parameters
section and it should work:
[$class : 'WHideParameterDefinition',
name : 'HIDDEN_PARAM',
description: 'Hidden param for...']
Hope this helps you as well.
Upvotes: 3