Hi Sophie
It works in a pipeline when I have that code in a function and have it 
return the values, like this:
def getuname(){
    withCredentials([usernamePassword(credentialsId: 'builduser', 
passwordVariable: 'PASSWD', usernameVariable: 'USRNAME')]) {
        // some block
        return USRNAME
    }
}


Good luck

On Wednesday, December 7, 2016 at 6:21:56 AM UTC-8, Sophie Field wrote:
>
> Hi Raja,
>
> Did you have any success with this? I'm using the withCredentials syntax 
> in a build but I can't use/access the variables stored globally. Also for a 
> pipeline project there isn't the option of including the variables in the 
> build from the Configure page like you get from a freestyle project. 
>
> On Tuesday, November 29, 2016 at 7:36:10 PM UTC, Raja Chinnam wrote:
>>
>> Hello
>>
>> How can I pass the username and password to my a custom application in 
>> the pipeline?
>> I have username and password added as credentials and am using this code:
>>
>> withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 
>> 'usrid', passwordVariable: 'USR', usernameVariable: 'PWD']]) {
>> bat '''
>> echo off
>> Query.exe -u %USR% -p %PWD%
>> '''
>> }
>>
>> my application fails with the message: 'invalid user "****"'
>>
>> thank you.
>>
>

-- 
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/c4611aea-c328-40bf-866c-8a3b16c5c554%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to