And that works great -- appreciate the help! -Arun
On Sunday, September 17, 2017 at 11:51:31 AM UTC-7, Daniel Butler wrote: > > The variables for the withCredentials step are created in the environment > map, to use them in the pipeline script you’ll need to refer them as > env.<varName> > > > > So for your case it would be: echo “${env.OD_USER}” > > That should run but all you’ll see is a bunch of *** as the > withCredentials step filters the log to prevent credentials leaking. > > > > Regards, > > Daniel. > > > > *From: *Arun Rao <javascript:> > *Sent: *17 September 2017 18:55 > *To: *Jenkins Users <javascript:> > *Subject: *withCredentials doesn't populate variables > > > > Very new to Jenkins and groovy, although I *thought* I was getting the > hang of it. > > > > For reasons beyond my control, we're running an older version of Jenkins > (1.651.3), so only the scripting pipeline is available, and not the > declarative one. > > > > I have the following groovy snippet from a job I'm attempting to write: > > > > timestamps { > > node('foo') > > { > > stage 'Foo' > > try { > > withCredentials([[$class: 'UsernamePasswordMultiBinding', > credentialsId: 'ac209643-f38d-4938-a28f-c7417f33db07', > > usernameVariable: 'OD_USER', passwordVariable: > 'OD_PASSWORD']]) { > > echo "$OD_USER" > > } > > } finally { > > } > > } > > } > > > > > > I know that the credentials are good, because they're used elsewhere in > "conventional" (non-pipeline) Jenkins jobs. But no matter what I try, this > code dies with a stack trace indicating that OD_USER is not defined. > > > > The only thing I can think of is that I'm running this code inline, rather > than fetching it via a Jenkinsfile sitting in an SCM. I have to check the > "Use Groovy Sandbox" box to get it to work, because I don't have Jenkins > administrator approval. I wonder if withCredentials doesn't work in this > situation, for security reasons. > > > > Any help would be appreciated. It doesn't look like we have a lot of > Jenkins experts at work! > > -- > You received this message because you are subscribed to the Google Groups > "Jenkins Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to jenkinsci-use...@googlegroups.com <javascript:>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jenkinsci-users/fd7572db-167b-4090-bfdc-711d485b4c89%40googlegroups.com > > <https://groups.google.com/d/msgid/jenkinsci-users/fd7572db-167b-4090-bfdc-711d485b4c89%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/b77a22b8-6769-4902-a400-53cc95ed3ba4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.