Re: How to replace withCredentials([usernamePassword ... with credentials(...)

2017-04-06 Thread Idan Adar
The problem was that it's not "PWD" but "PSW"...

On Thursday, April 6, 2017 at 6:26:00 PM UTC+3, Idan Adar wrote:
>
> In declarative pipeline, one can use credentials() instead 
> of withCredentials, but I am not really sure how this works. In general, 
> lots of examples are missing...
>
> Assuming I've created in Jenkins a credential for an access token, I can 
> do this:
>
> stage ("Merge pull request") {
> environment {
>  ACCESS_TOKEN = credentials('credentials_id')
> }
>   
> steps {
> ... $ACCESS_TOKEN
> }
> }
>
> But how do I handle username/password variables with credentials()?
> Assuming I've created credentials for a username/password combination, 
> previously it'd be like this:
>
> withCredentials([usernamePassword(credentialsId: 'credentials_id', 
> usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {   
>
> ... $USERNAME
> ... $PASSWORD
> }
>
>

-- 
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/f4c9858f-96c7-4113-955f-617d7686a90c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to replace withCredentials([usernamePassword ... with credentials(...)

2017-04-06 Thread Idan Adar
There's a missing ' below, just a copy/paste mistake. The error still 
happens, and also with a different credential, the same one used for the 
checkout... so I know 100% that the values in it are valid and working... 
but it fails with that _PWD...

On Thursday, April 6, 2017 at 9:05:27 PM UTC+3, Idan Adar wrote:
>
> The following resulted in an exception during runtime.
>
> groovy.lang.MissingPropertyException: No such property: UP_PWD for class: 
> groovy.lang.Binding
>   at groovy.lang.Binding.getVariable(Binding.java:63)
>   at 
> org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:224)
>   at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241)
>   at 
> org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238)
>   at 
> org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
>   at 
> org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
>   at 
> org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
>   at 
> org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
>   at 
> com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:28)
>   at 
> com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
>   at WorkflowScript.run(WorkflowScript:126)
> ...
> ...
>
>
>
>
> stage ("...") {
>  environment {
> UP = credentials('...)
>  }
>  
>  when {
> branch "develop"
>  }
>  
>  steps {
> 
> sh "cf login ... -u $UP_USR -p $UP_PWD"
>  }
>   }
>
>
> On Thursday, April 6, 2017 at 7:42:04 PM UTC+3, Andrew Bayer wrote:
>>
>> FOO = credentials('id') will create environment variables FOO_USR and 
>> FOO_PWD
>>
>> On Apr 6, 2017 8:42 AM, "Idan Adar"  wrote:
>>
>> Perhaps Robert (CCed) can help?
>>
>>
>> On Thursday, April 6, 2017 at 6:26:00 PM UTC+3, Idan Adar wrote:
>>>
>>> In declarative pipeline, one can use credentials() instead 
>>> of withCredentials, but I am not really sure how this works. In general, 
>>> lots of examples are missing...
>>>
>>> Assuming I've created in Jenkins a credential for an access token, I can 
>>> do this:
>>>
>>> stage ("Merge pull request") {
>>> environment {
>>>  ACCESS_TOKEN = credentials('credentials_id')
>>> }
>>>   
>>> steps {
>>> ... $ACCESS_TOKEN
>>> }
>>> }
>>>
>>> But how do I handle username/password variables with credentials()?
>>> Assuming I've created credentials for a username/password combination, 
>>> previously it'd be like this:
>>>
>>> withCredentials([usernamePassword(credentialsId: 'credentials_id', 
>>> usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {   
>>>
>>> ... $USERNAME
>>> ... $PASSWORD
>>> }
>>>
>>> -- 
>> 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.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/f25e52a4-f28a-4738-8901-c3500bd1d952%40googlegroups.com
>>  
>> 
>> .
>>
>> 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/8bd0281e-b42e-47a0-9631-8aa4f39a1d31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to replace withCredentials([usernamePassword ... with credentials(...)

2017-04-06 Thread Idan Adar
The following resulted in an exception during runtime.

groovy.lang.MissingPropertyException: No such property: UP_PWD for class: 
groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)
at 
org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:224)
at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241)
at 
org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238)
at 
org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
at 
org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
at 
org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
at 
org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
at 
com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:28)
at 
com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at WorkflowScript.run(WorkflowScript:126)
...
...




stage ("...") {
 environment {
UP = credentials('...)
 }
 
 when {
branch "develop"
 }
 
 steps {

sh "cf login ... -u $UP_USR -p $UP_PWD"
 }
  }


On Thursday, April 6, 2017 at 7:42:04 PM UTC+3, Andrew Bayer wrote:
>
> FOO = credentials('id') will create environment variables FOO_USR and 
> FOO_PWD
>
> On Apr 6, 2017 8:42 AM, "Idan Adar" > wrote:
>
> Perhaps Robert (CCed) can help?
>
>
> On Thursday, April 6, 2017 at 6:26:00 PM UTC+3, Idan Adar wrote:
>>
>> In declarative pipeline, one can use credentials() instead 
>> of withCredentials, but I am not really sure how this works. In general, 
>> lots of examples are missing...
>>
>> Assuming I've created in Jenkins a credential for an access token, I can 
>> do this:
>>
>> stage ("Merge pull request") {
>> environment {
>>  ACCESS_TOKEN = credentials('credentials_id')
>> }
>>   
>> steps {
>> ... $ACCESS_TOKEN
>> }
>> }
>>
>> But how do I handle username/password variables with credentials()?
>> Assuming I've created credentials for a username/password combination, 
>> previously it'd be like this:
>>
>> withCredentials([usernamePassword(credentialsId: 'credentials_id', 
>> usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {   
>>
>> ... $USERNAME
>> ... $PASSWORD
>> }
>>
>> -- 
> 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 .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-users/f25e52a4-f28a-4738-8901-c3500bd1d952%40googlegroups.com
>  
> 
> .
>
> 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/38a60623-c2ce-40c9-8fcd-a31acf264e73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to replace withCredentials([usernamePassword ... with credentials(...)

2017-04-06 Thread Andrew Bayer
FOO = credentials('id') will create environment variables FOO_USR and
FOO_PWD

On Apr 6, 2017 8:42 AM, "Idan Adar"  wrote:

Perhaps Robert (CCed) can help?


On Thursday, April 6, 2017 at 6:26:00 PM UTC+3, Idan Adar wrote:
>
> In declarative pipeline, one can use credentials() instead
> of withCredentials, but I am not really sure how this works. In general,
> lots of examples are missing...
>
> Assuming I've created in Jenkins a credential for an access token, I can
> do this:
>
> stage ("Merge pull request") {
> environment {
>  ACCESS_TOKEN = credentials('credentials_id')
> }
>
> steps {
> ... $ACCESS_TOKEN
> }
> }
>
> But how do I handle username/password variables with credentials()?
> Assuming I've created credentials for a username/password combination,
> previously it'd be like this:
>
> withCredentials([usernamePassword(credentialsId: 'credentials_id',
> usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
>
> ... $USERNAME
> ... $PASSWORD
> }
>
> --
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/f25e52a4-f28a-4738-8901-c3500bd1d952%40googlegroups.
com

.

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/CAPbPdOaKbJ1MiZbX_N_NAGHcakJd2bOF6YdRuc92bOP8bbnCFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to replace withCredentials([usernamePassword ... with credentials(...)

2017-04-06 Thread Idan Adar
Perhaps Robert (CCed) can help?

On Thursday, April 6, 2017 at 6:26:00 PM UTC+3, Idan Adar wrote:
>
> In declarative pipeline, one can use credentials() instead 
> of withCredentials, but I am not really sure how this works. In general, 
> lots of examples are missing...
>
> Assuming I've created in Jenkins a credential for an access token, I can 
> do this:
>
> stage ("Merge pull request") {
> environment {
>  ACCESS_TOKEN = credentials('credentials_id')
> }
>   
> steps {
> ... $ACCESS_TOKEN
> }
> }
>
> But how do I handle username/password variables with credentials()?
> Assuming I've created credentials for a username/password combination, 
> previously it'd be like this:
>
> withCredentials([usernamePassword(credentialsId: 'credentials_id', 
> usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {   
>
> ... $USERNAME
> ... $PASSWORD
> }
>
>

-- 
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/f25e52a4-f28a-4738-8901-c3500bd1d952%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to replace withCredentials([usernamePassword ... with credentials(...)

2017-04-06 Thread Idan Adar
In declarative pipeline, one can use credentials() instead 
of withCredentials, but I am not really sure how this works. In general, 
lots of examples are missing...

Assuming I've created in Jenkins a credential for an access token, I can do 
this:

stage ("Merge pull request") {
environment {
 ACCESS_TOKEN = credentials('credentials_id')
}
  
steps {
... $ACCESS_TOKEN
}
}

But how do I handle username/password variables with credentials()?
Assuming I've created credentials for a username/password combination, 
previously it'd be like this:

withCredentials([usernamePassword(credentialsId: 'credentials_id', 
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {   

... $USERNAME
... $PASSWORD
}

-- 
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/a2b12a7e-dd47-410c-a92e-b8c8ef45cb33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.