mbelosto
mbelosto

Reputation: 66

How to get github API endpoint and scan credentials inside Jenkinsfile

How can I get the github API endpoint and scan-credentials id inside my pipeline Jenkinsfile to run Github API request.

I am using github organization folder plugin.

Upvotes: 3

Views: 1147

Answers (2)

Ryan
Ryan

Reputation: 604

You use the "withCredentials" to expose the secrets. (Obviously echoing the secret out would be a bad way to keep it secret - but you could pass that secret on to other things that didn't print it out...)

 withCredentials([[$class : 'StringBinding',
                   credentialsId   : 'my_secret_token',
                   variable: 'GHE_TOKEN',
                ]]) {
     echo "I can access my secret token of  ${env.GHE_TOKEN} now"
 }

Upvotes: 1

Jesse Glick
Jesse Glick

Reputation: 25481

You would need to have picked a mnemonic ID for the credentials, and then hardcode that in the Jenkinsfile. At that point you can use the Credentials Binding plugin to retrieve the actual secret.

Upvotes: 0

Related Questions