30
loading...
This website collects cookies to deliver better user experience
We head over to Canonic and sign in using our social accounts. Next, we click on Create New to create a project for our application. Click on next, then click on create to complete the process.
Create new project screen
A popup asking your first table name will appear. If not, you can click on the + icon in the header to create a new table. Let's name our first & only table for this project - RepoBuilds.
We create a text field named "Repo Branch" as we need the branch name against which we want to trigger the build.
We hit deploy on the top right, and we'll be provided with a hosted backend. a database & basic CRUD endpoints per table.
Click on the API tab on the left to start adding the Travis CI webhook. We select + button that's attached to the createRepoBuilds block in mutations. It'll open up a new webhook settings on the right hand side.
Select Build type → Choose Travis CI from the list of providers & you'll be provided with fields for settings.
API Key → This is the API key of Travis account.
Repo Url → Git URL for the Repo we want to trigger the build
Repo Branch → Branch to be selected for building
For Repo Branch → We want to trigger the build against the text found in the repo branch field of the API payload. So we can make use of Handlebars templates & simply write {{repoBranch}}
in that field. This will extract the repoBranch field from the API payload and forward it to Travis.
Our curl command will look something like this.
➜ ~ curl 'https://xxxx.hem.canonic.dev/api/repoBuilds' \
--request POST \
--header "Content-type: application/json" \
--header "Authorization: xxxxxx-xxxxx-xxxx" \
--data '{
"input": {
"repoBranch": "newFixes",
}
}'
A successful response will look like this:
{"data":{"repoBranch":"newFixes","_id":"60bf30ee2529700009fd2a4a","createdAt":"2021-06-08T08:57:18.316Z","updatedAt":"2021-06-08T08:57:18.316Z","__v":0,"id":"60bf30ee2529700009fd2a4a"},"error":null,"success":true}%