We are happy to announce the addition of sequential parameterized builds to our feature list. Using this feature, you can trigger a sequence of CI workflows for your projects and even pass parameters from one build to another!
You will want to do this in 2 situations:
- you have build dependencies, and if one codebase changes, you want to trigger builds for all dependent codebases. A great example of this is that you have a base Docker image
foo/appBase for your application and all services have a FROM
foo/appBase:latest in their Dockerfiles. With this new feature, you can easily trigger builds for all your services if the base image
- your have codebases that need to be triggered sequentially since each build produces parameters required by the next build in the sequence.
This new feature is documented here in greater detail.
Let's look at a more detailed example of how this will work in practice.
For this example, I have 2 GitHub repositories - manishas/u14nod which has the Dockerfilefor base nodejs image that i use for my application, which is at manishas/sample_nodejs. I want to set up my CI workflow for the base image so that every time it changes, it also triggers CI for the application and also passes a parameter.
Both projects are enabled on Shippable.
To enable the sequential build workflow, we will first add an account integration for the trigger and then add the integration to the yml for the base image.
1. Creating an API token
You will first need to create an API token since you'll need it while creating your account integration. To do this, go to your Account Settings by clicking on the gear icon in the top navigation bar of your Shippable dashboard.
API Tokens section, enter a token name in the textbox and click on
Add. Copy the token you just created by clicking on
Copy. Remember to copy it somewhere since you will not be able to copy or view the token once you leave the Account Settings page.
2. Adding an account integration of type Event Trigger
From the build page for manishas/u14nod Click on Settings and click on
Integrations->Select notifications integration
Create a new notification integration as shown below:
Event Trigger in the dropdown for
- Name your integration with an easy to remember friendly name.
- In the next dropdown, select
Project. This will show a dropdown with all projects enabled on Shippable. Select the project you want to trigger. In my case, this is manishas/sample_nodejs.
Authorization, paste the API token you created in the previous step.
3. Editing the yml
Next, edit the yml for the base image manishas/u14nod
integrations: notifications: - integrationName: trigger_samplenodejs type: webhook payload: - TRIGGER_REASON=BaseImgChanged
In integrationName, enter the name of the account integration you created in the step above. type for this scenario is always webhook. In the payload section, you can enter any number of parameters you want to pass to the next build. For this example, I've include one parameter TRIGGER_REASON so that the next build knows why it was triggered. If needed, I can tweak my workflows for the triggered build based on this parameter, which will be available as an environment variable during the triggered build.
And that's it! Triggering a build for the base image will now trigger CI for the application if CI for the base image passes. You have successfully set up sequential, parameterized builds.
Let us know if you have any questions or want to share your feedback! Happy Shipping!