Concourse: Trigger a job with a HTTP request

拥有回忆 提交于 2019-12-10 18:09:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!