I have done the following:

1. Create a "secret text" type credential
2. Put in the credential a password
3. Create a Global Variable, mySecret, with its value being the credential 
ID
4. In the declarative pipeline: 

stage ("E2E tests") {  
         environment {
            mySecret = credentials('${mySecret}')
         }
             
         steps {
            script {
               STAGE_NAME = "E2E tests"
               echo "++++++++++++ $mySecret"


               if (JOB_NAME == "e2e-dev") {
                  // Setup packages and run tests
                  sh '''
                     rm -f config/e2e-config.json
                     mv config/e2e-dev-config.json config/e2e-config.json
                     npm install
                     npm test
                  '''
               }
           }
        }
}

In Jenkins, the secret text is printed: "*****"
In the NodeJS app, I'm getting an error...

Global Variables in Jenkins can also be used as environment variables and I 
know I can use those as clear text in the NodeJS app.
My question is how to use Jenkins credentials from Jenkins in the NodeJS 
app...

Any thoughts?

-- 
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/49e5cabe-6916-4c1f-a0a5-c7bd146725a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to