Hello guys first time writting here was wondering If I culd get some help:

I have a jenkins pipeline from SCM running in jenkins with a groovyscript. 
In one of the steps I have upload a file to artifactory with CURL - u 
user:pass , but don´t wan´t that user and pass be visible in output of 
pipeline in jenkins. I have read in several places the "Withcredential" 
function but I´m not quite sure how to this works or apply or implement. I 
tried this 2 options with no luck:

stage ('Upload war to Artifactory') {
                withCredentials([usernamePassword(credentialsId: 
'artifactory', usernameVariable: 'user', passwordVariable: 'Password')])
               sh "sudo curl -u $user:$password -T $warPath 
'https://artifactory.uuuuuu.com:443/artifactory/orm/$warFile'"

            }

In this case I´m getting:

*org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException: 
artifactory** at 
org.jenkinsci.plugins.credentialsbinding.MultiBinding.getCredentials(MultiBinding.java:153)
 
at 
org.jenkinsci.plugins.credentialsbinding.impl.UsernamePasswordMultiBinding.bind(UsernamePasswordMultiBinding.java:76)
 
at 
org.jenkinsci.plugins.credentialsbinding.impl.BindingStep$Execution.start(BindingStep.java:114)
 
at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:229) at 
org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:153) at 
org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108) 
at 
groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278) 
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172) at 
groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at 
groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)*



Where does the credential ID taken from? how does this function works 
inside the groovy script? I also tried this other way that I read but It 
uses a class like obect oriented, and instead of 


*usernamePassword* it uses *UsernamePasswordMultiBinding*



*withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 
'artifactory', usernameVariable: 'username', passwordVariable: 
'password']])*




*and it gives me following error:*



*[Pipeline] End of Pipeline java.lang.IllegalStateException: There is no 
body to invoke at 
org.jenkinsci.plugins.workflow.cps.CpsStepContext.newBodyInvoker(CpsStepContext.java:283)
 
at 
org.jenkinsci.plugins.workflow.cps.CpsStepContext.newBodyInvoker(CpsStepContext.java:95)
 
at 
org.jenkinsci.plugins.credentialsbinding.impl.BindingStep$Execution.start(BindingStep.java:118)
 
at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:229) at 
org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:153) at 
org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108) 
at 
groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278) 
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172)*




*I also installed credential plug in in which I store user and pass 
globally and created a user ID which I then use in "withcredentials" ( 
credentialsId: 'artifactory'), but I think that Id is not related at all. I 
did some research but is not quite well explained the use of this function, 
and if It can be used inside a groovyscript for a jenkins pipeline from 
SCM. Can some one please explain how can I achieve this?.*

*I´m attaching my groovy script so you can see. *

*If is not this way, how can I achieve to use user and pass on job output 
but that they don´t appear (or appear like ***)*

-- 
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/ab396089-399b-4208-9755-978642069117%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: Extractor.groovy
Description: Binary data

Reply via email to