Search code examples
jenkinsjenkins-cli

Authenticate with remote jenkins using CLI


I run this:

curl "$JENKINS_URL/job/simple_starter/build?token=$TOKEN_NAME" 

but I got this message:

Authentication required You are authenticated as: anonymous Groups that you are in: Permission you need to have (but didn't): hudson.model.Hudson.Read ... which is implied by: hudson.security.Permission.GenericRead ... which is implied by: hudson.model.Hudson.Administer

I figure I can login using something like this:

java -jar jenkins-cli.jar --password x --username y

but how do I pass my creds with the curl command so that I can trigger a Jenkins job manually?


Solution

  • All I had to do was add my Jenkins username/password to the curl command like so:

    curl -u "${jenkins_username}:${jenkins_password}" "$JENKINS_URL/xyz"