2

Is there an API can be used to trigger a pipeline, I did not find one in the API manual. Or, is there any other way I can trigger a pipeline using linux command?

Thanks

WeDBA
  • 343
  • 4
  • 7

2 Answers2

2

link to the docs: https://api.gocd.org/current/#scheduling-pipelines

POST /go/api/pipelines/:pipeline_name/schedule

in the request you can override the environmental variables, the material to use and choose to update the material before the start.

command example as taken from the documentation:

$ curl 'https://ci.example.com/go/api/pipelines/pipeline1/schedule' \
       -u 'username:password' \
       -H 'Accept: application/vnd.go.cd.v1+json' \
       -H 'Content-Type: application/json' \
       -X POST \
       -d '{
             "environment_variables": [
               {
                 "name": "USERNAME",
                 "secure": false,
                 "value": "bob"
               },
               {
                 "name": "SSH_PASSPHRASE",
                 "value": "some passphrase",
                 "secure": true,
               },
               {
                 "name": "PASSWORD",
                 "encrypted_value": "YEepp1G0C05SpP0fcp4Jh+kPmWwXH5Nq",
                 "secure": true,
               }
             ],
             "materials": [
               {
                 "fingerprint": "b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c",
                 "revision": "123"
               },
               {
                 "fingerprint": "7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730",
                 "revision": "1058e75b18e8a645dd71702851994a010789f450"
               }
             ],
             "update_materials_before_scheduling": true
           }'
biruk1230
  • 3,042
  • 4
  • 16
  • 29
thorxas
  • 21
  • 3
0

/go/api/pipelines/${pipelineName}/schedule works

WeDBA
  • 343
  • 4
  • 7