Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concourse: Trigger a job with a HTTP request

I am trying to trigger a Concourse job with a web hook on my Git server. Following this issue on Github I found an endpoint definition. So I tried

curl http://10.20.30.101:8080/api/v1/pipelines/helloworld/resources/resource-tutorial/check -X POST

where helloworld is the name of my pipeline and resource-tutorial is the name of the resource for which I want to trigger a check.

But Concourse returns

404 page not found

What am I doing wrong? Can someone point me to the correct endpoint?

like image 586
Michael Lihs Avatar asked Oct 31 '25 13:10

Michael Lihs


2 Answers

For now there is web hook token for resource: https://concourse-ci.org/configuring-resources.html#webhook_token

/api/v1/teams/TEAM_NAME/pipelines/PIPELINE_NAME/resources/RESOURCE_NAME/check/webhook?webhook_token=WEBHOOK_TOKEN

You can add web hook here: https://github.com/<username>/<repo>/settings/hooks/new

like image 115
Alex Bender Avatar answered Nov 02 '25 05:11

Alex Bender


After some investigation and with help from the very supportive concourse slack channel, I figured out the following solution (which doesn't allow triggering a job via HTTP GET request but is a good start).

First create a new team as described in the documentation (go for the basic auth solution):

fly set-team -n my-team \
  --basic-auth-username ci \
  --basic-auth-password changeme

Now generate a authentication token with:

curl -u foo:bar http://<CONCOURSE HOSTNAME>:<CONCOURSE PORT>/api/v1/teams/my-team/auth/token

{"type":"Bearer","value":"... VERY LONG TOKEN..."}

You can now trigger a build by using the VERY LONG TOKEN as a cookie with:

curl -v --cookie "ATC-Authorization=Bearer VERY LONG TOKEN" \
  http://<CONCOURSE HOSTNAME>:<CONCOURSE PORT>/api/v1/teams/my-team/pipelines/<PIPELINE NAME>/jobs/<JOB NAME>/builds -X POST

Now the job is being triggered.

like image 39
Michael Lihs Avatar answered Nov 02 '25 05:11

Michael Lihs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!