In Ubuntu, how do I authenticate to trigger a Jenkins job remotely using the CLI?



  • As far as I understand, using the Linux CLI, builds can be triggered remotely using the curl command and the following URL syntax:

    /job//build?token=

    Example:

    $ curl http://localhost:8080/job/MyJob/build?token=my-token
    

    However, when I run the command, I receive the following:

    Authentication required
    
    
    

    Is authentication done using the CLI or the Jenkins web interface? How do I authenticate?



  • This is covered https://www.jenkins.io/doc/book/system-administration/authenticating-scripted-clients/ . In short, if you are triggering via HTTP, you need to generate an authentication token and use it with HTTP Basic auth, for instance:

    curl -X POST -L --user your-user-name:apiToken https://jenkins.example.com/job/your_job/build
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2