Reputation: 1557
I'm trying to add a passwordParam
to my Jenkins groovy file as such.
The intention is to have the password picked up by a job at runtime
pipelineJob(jobName) {
displayName(displayString)
parameters {
choiceParam('ARTEFACT',artefactName,'Artefact to deploy?')
choiceParam('CLUSTER',cluster,'Cluster to push to')
stringParam('BRANCH','main','What branch should be used?')
passwordParam('proxyUser', 'password123', 'ProxyPassword')
}
But I get the error
ERROR: (job_delete_release.groovy, line 23) No signature of method: javaposse.jobdsl.dsl.helpers.BuildParametersContext.passwordParam() is applicable for argument types: (java.lang.String, java.lang.String, java.lang.String) values: [proxyUser, password123, ProxyPassword]
According to the documentation here it should be possible.
I'm not sure what I'm doing wrong or if I'm missing something really obvious.
Upvotes: 0
Views: 1540
Reputation: 1962
It looks like you are mixing DSL and Declarative syntaxs.
What you are writing here is JobDSL, however your link is to declarative code. In the section you are writing you can only use the parameters available to JobDSL which can be found here:
Click the three dots in the parameters on https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.jobs.MavenJob.parameters
So for the JobDSL I believe you would use nonStoredPasswordParam
(note I have never used it)
If you wanted your parameters in Declarative you would write them inside the pipeline
section.
e.g.
pipeline {
agent any
parameters {
string(name: 'script_args', defaultValue: '--out_file --purge', description: 'Command line args to pass to script')
}
Upvotes: 1