1

In Jenkins pipeline parameter say Branches of type Active Choice Reactive Parameter, I've to auto-populate branch names hence I've following command, which I can execute in parameter's Groovy script -

svn ls <url> --non-interactive --no-auth-cache --trust-server-cert --username <username>--password <password>

username can be retrieved using User.current().getId()

I've Password parameter of Password Parameter type. To use value of this parameter in Groovy script of Branches, I've added Password parameter in Referenced parameters of Branches

But I cannot see its value reflected in Branches parameter. Can you please suggest how this can be handled?

Or any other way to pass Password value or authentication details so I can execute svn command.

  • Code and everything was correct. Only thing is I was not having correct password in Password parameter, hence expected result was not returned. – Alpha Jun 23 '20 at 12:19
-1

Could credentials binding plugin be the answer?

The idea is to add svn user and password to Jenkins credentials store and then use it in the pipeline.

withCredentials([
    usernamePassword(
        credentialsId: 'mySvnLogin',
        usernameVariable: 'USER',
        passwordVariable: 'PASSWORD')]) {
    sh '''
      svn ls <url> --non-interactive --no-auth-cache --trust-server-cert --username $USER 
 --password $PASSWORD
    ''''
  • Active Choice parameters use Groovy scripts which are not part of Pipeline code. withCredentials is a Pipeline step and is therefore unavailable in the Groovy scripts for Active Choice parameters. – jayhendren Jun 22 '20 at 1:22
  • Code and everything was correct. Only thing is I was not having correct password in Password parameter, hence expected result was not returned. – Alpha Jun 23 '20 at 12:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.