Start Jenkins build using batch script

后端 未结 6 1996
挽巷
挽巷 2020-12-15 23:43

I am working with a Jenkins build server to run synthesis/simulation for FPGAs. Right now I have nightly builds and can start the build manually in Jenkins browser interface

6条回答
  •  无人及你
    2020-12-16 00:11

    You can trigger a Jenkins job with a configured token instead of your username/password, which would allow you to share a trigger script without exposing your own credentials.

    1. Go to your job's configuration.
    2. Scroll down to Build Triggers, and check the box for Trigger build remotely (e.g., from scripts), and enter an authentication token (e.g., "MY_TOKEN").

    1. Copy one of the URLs below the Authentication Token field based on whether your build has parameters.

    Then use that URL in a curl command to trigger a build. For example:

    curl -I https://${JENKINS_URL}/job/tmp/job/dummy-test/build?token=MY_TOKEN
    

    The -I parameter tells curl to print the head of the response, which you could use to determine the result status. Jenkins replies with HTTP 201 if successful:

    $ curl -I https:///job/tmp/job/dummy-test/build\?token\=MY_TOKEN
    HTTP/1.1 201 Created
    Cache-Control: public
    Content-Length: 0
    Date: Mon, 11 Apr 2016 12:47:26 GMT
    Location: https:///queue/item/1707/
    Pragma: public
    Server: Apache-Coyote/1.1
    X-Content-Type-Options: nosniff
    Connection: keep-alive
    

提交回复
热议问题