问题
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?
回答1:
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
回答2:
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.
来源:https://stackoverflow.com/questions/41823945/concourse-trigger-a-job-with-a-http-request