|
| 1 | +[id="manage-builds-api"] |
| 2 | += Managing builds by using the {productname} API |
| 3 | + |
| 4 | +Builds can be managed by using the {productname} API. |
| 5 | + |
| 6 | +.Procedure |
| 7 | + |
| 8 | +. Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#listbuildtriggers[`GET /api/v1/repository/{repository}/trigger/`] endpoint to list the triggers for the specified repository: |
| 9 | ++ |
| 10 | +[source,terminal] |
| 11 | +---- |
| 12 | +$ curl -X GET "https://quay-server.example.com/api/v1/repository/example_namespace/example_repo/trigger/" \ |
| 13 | + -H "Authorization: Bearer <your_access_token>" |
| 14 | +---- |
| 15 | ++ |
| 16 | +.Example output |
| 17 | ++ |
| 18 | +[source,terminal] |
| 19 | +---- |
| 20 | +{"triggers": [{"id": "32ca5eae-a29f-46c7-8f44-3221ca417c92", "service": "custom-git", "is_active": false, "build_source": null, "repository_url": null, "config": {}, "can_invoke": true, "enabled": true, "disabled_reason": null}]} |
| 21 | +---- |
| 22 | + |
| 23 | +. Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#activatebuildtrigger[`POST /api/v1/repository/{repository}/trigger/{trigger_uuid}/activate`] endpoint to activate the specified build trigger. |
| 24 | ++ |
| 25 | +[source,terminal] |
| 26 | +---- |
| 27 | +$ curl -X POST "https://quay-server.example.com/api/v1/repository/example_namespace/example_repo/trigger/example-trigger-uuid/activate" \ |
| 28 | + -H "Authorization: Bearer <your_access_token>" \ |
| 29 | + -H "Content-Type: application/json" \ |
| 30 | + -d '{ |
| 31 | + "config": { |
| 32 | + "branch": "main" |
| 33 | + }, |
| 34 | + "pull_robot": "example+robot" |
| 35 | + }' |
| 36 | +---- |
| 37 | + |
| 38 | +. Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#manuallystartbuildtrigger[`POST /api/v1/repository/{repository}/trigger/{trigger_uuid}/start`] endpoint to manually start the build from the specified trigger: |
| 39 | ++ |
| 40 | +[source,terminal] |
| 41 | +---- |
| 42 | +$ curl -X POST "https://quay-server.example.com/api/v1/repository/example_namespace/example_repo/trigger/example-trigger-uuid/start" \ |
| 43 | + -H "Authorization: Bearer <your_access_token>" \ |
| 44 | + -H "Content-Type: application/json" \ |
| 45 | + -d '{ |
| 46 | + "branch_name": "main", |
| 47 | + "commit_sha": "abcdef1234567890", |
| 48 | + "refs": "refs/heads/main" |
| 49 | + }' |
| 50 | +---- |
| 51 | + |
| 52 | +. Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#listtriggerrecentbuilds[`GET /api/v1/repository/{repository}/trigger/{trigger_uuid}/builds`] endpoint to list the builds started by the specified trigger: |
| 53 | ++ |
| 54 | +[source,terminal] |
| 55 | +---- |
| 56 | +$ curl -X GET "https://quay-server.example.com/api/v1/repository/example_namespace/example_repo/trigger/example-trigger-uuid/builds?limit=10" \ |
| 57 | + -H "Authorization: Bearer <your_access_token>" |
| 58 | +---- |
| 59 | + |
| 60 | +. Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#getbuildtrigger[`GET /api/v1/repository/{repository}/trigger/{trigger_uuid}`] endpoint to get information for the specified build trigger: |
| 61 | ++ |
| 62 | +[source,terminal] |
| 63 | +---- |
| 64 | +$ curl -X GET "https://quay-server.example.com/api/v1/repository/example_namespace/example_repo/trigger/example-trigger-uuid" \ |
| 65 | + -H "Authorization: Bearer <your_access_token>" |
| 66 | +---- |
| 67 | + |
| 68 | +. Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#updatebuildtrigger[`PUT /api/v1/repository/{repository}/trigger/{trigger_uuid}`] endpoint to update the specified build trigger: |
| 69 | ++ |
| 70 | +[source,terminal] |
| 71 | +---- |
| 72 | +$ curl -X PUT "https://quay-server.example.com/api/v1/repository/example_namespace/example_repo/trigger/example-trigger-uuid" \ |
| 73 | + -H "Authorization: Bearer <your_access_token>" \ |
| 74 | + -H "Content-Type: application/json" \ |
| 75 | + -d '{"enabled": true}' |
| 76 | +---- |
| 77 | + |
| 78 | +. Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#deletebuildtrigger[`DELETE /api/v1/repository/{repository}/trigger/{trigger_uuid}`] endpoint to delete the specified build trigger: |
| 79 | ++ |
| 80 | +[source,terminal] |
| 81 | +---- |
| 82 | +$ curl -X DELETE "https://quay-server.example.com/api/v1/repository/example_namespace/example_repo/trigger/example-trigger-uuid" \ |
| 83 | + -H "Authorization: Bearer <your_access_token>" |
| 84 | +---- |
0 commit comments