Home > database >  Masking Basic Auth header when using CURL to trigger remote jenkins job
Masking Basic Auth header when using CURL to trigger remote jenkins job

Time:09-09

I want to trigger remote Jenkins job from my container(k8s).

Currently, I'm using:

curl -k -X POST -u $USER:$JENKINS_TOKEN "${JENKINS_URL}/job/{$JOB_NAME}/buildWithParameters?token=12345"

But this information($USER,$JENKINS_TOKEN) is displayed in ArgoUI, is there any secure/other way to save credentials for remote trigger?

CodePudding user response:

You can try one of the following.

Save the password in a file called password-file and read from that

curl -k -X POST -u $USER:$(cat .password-file)"${JENKINS_URL}/job/{$JOB_NAME}/buildWithParameters?token=12345"

Accept credentials from the STDIN.

curl -k -X POST "${JENKINS_URL}/job/{$JOB_NAME}/buildWithParameters?token=12345" -K- <<< "--user $USER:$JENKINS_TOKEN"

You can also try using --netrc-file option with curl where you can store the username and password in a file itself.

file

machine JENKINS_HOST login USERNAME password PASSWORD

Curl Command

curl -k -X POST --netrc-file my-password-file "${JENKINS_URL}/job/{$JOB_NAME}/buildWithParameters?token=12345"
  • Related