Continuous delivery is awesome. Nothing beats the ease of delivering code and having your entire pipeline kick off, updating your application, without you having to do anything.
Bluemix makes this easy to do.
Configuring a pipeline with Bluemix and GitHub is split in two parts - creating an IBM Devops project, and configuring your pipeline. Creating the Devops project is as simple as clicking a few buttons and linking your Bluemix project to a GitHub repo. Configuring your pipeline is as simple as adding a few stages and jobs that feed in to each other.
There are a lot of screenshots in this post, but fear not - they’re here to make things easier to explain, not because this is a difficult process.
- A Bluemix account
- An IBM Devops account
- A Github account
- Create a Bluemix Project
- Push that project’s code to a Github Repo
Part 1: Configure your Devops project.
Navigate on over to IBM Devops, and click “Create Project”
Name your project and click on “link to an existing GitHub repository.” By convention, I prefer to name my IBM Devops project the same name as my Bluemix project.
Select the repo that contains the code for your project.
Now it’s project configuration time. For the purposes of this demo, we’re going to make it private and without scrum development tools.
Make sure to select “Make this a Bluemix Project,” otherwise you won’t be able to push the updates. Select the proper organization and space that houses your application.
You should see a success notification. To get to the build pipeline view for “Part 2,” click the “build & deploy button.
For a sanity check, you can verify that the following webhook was added to your GitHub repo:
Part 2: Configure your build pipeline.
Full docs here.
In this example, we’re going to be creating two stages: test/build and deploy. The test/build stage is going to have three jobs - install dependencies, test, and build. The deploy stage will only have one job - deploy.
Let’s start by creating a stage - click “Add Stage.”
Name this stage “Test + Build.” Make sure that “Run jobs whenever a change is pushed to Git” is selected.
We’re going to add three “build” jobs:
For the purposes of this demo, we’re going to use npm for our “Builder Type.” We
also have our npm scripts configured such that
test runs our tests, and
build does our build.
Stage 1, “Install Dependencies” uses as a build script:
Stage 2, “Test” uses as a build script:
npm run test
Stage 3, “Build” uses as a build script:
npm run build
Now all we need to do is create our deploy stage (by clicking add stage again):
And then create a deploy job in our deploy stage.
For both of these, I’ve always found the defaults to be sufficient.
Part 3: Relax.
Now every time you push to your GitHub repo, your pipeline will run.