4

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?

Michael Lihs
  • 7,460
  • 17
  • 52
  • 85

2 Answers2

5

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

Dwayne Forde
  • 1,324
  • 13
  • 13
Alex Bender
  • 846
  • 13
  • 26
4

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.

Michael Lihs
  • 7,460
  • 17
  • 52
  • 85
  • Did this work for you ? I am not able to send the post request to trigger the pipeline . This is my code – Vidya Jun 10 '17 at 08:12
  • import requests cookie = {'ATC-Authorization': 'Bearer eyJhbG3hVo1KXsg2Ce6-xlew'} r = requests.post('http://192.168.100.4:8080/api/v1/teams/main/pipelines/mm/jobs/job-test-app/builds' , cookies=cookie) dir(r) print r.text – Vidya Jun 10 '17 at 08:12
  • 4.0.0 seems to ship with a new login system. What worked for me was `curl -v 'http://localhost:8080/api/v1/teams/main/builds' -H 'Authorization: Bearer VERY LONG TOKEN` with the token extracted from ~/.flyrc (having logged in via fly before). – cburgmer Oct 28 '18 at 16:42