Bluemix Deployment

Link Existing GitHub Repo with Bluemix and Set up Continuous Integration

It is a fair assumption that a lot of developers would be interested Bluemix platform functionalities blended in with something that they already developed. This chapter would help developers to integrate a project hosted on the GitHub with the Bluemix platform and to set up a continuous integration cycle with every commit and push to the GitHub. After following the steps below you would be able to link your GitHub repository with your Bluemix account, make changes to your projects in your favorite text editor, push those changes to the GitHub and watch from the Bluemix dashboard how it is picked up automatically and a build/deploy processes are triggered. After the deployment is finished you would be able to access your application in the cloud.

Set up a GitHub repository

  1. 1.
    Create a New Repo on GitHub. Click Create a new Repository
  2. 2.
    Optional: add README and .gitignore
  3. 3.
    Copy the gitHub url for this repo
  4. 4.
    On your local machine go into the project folder
  5. 5.
    Initialize git with: git init
  6. 6.
    Type: git add .
  7. 7.
    Type: git commit -m “First commit”
  8. 8.
    Type: git remote add origin <your_repo_url>
  9. 9.
    Type: git push
  10. 10.
    Now the project is on the github and ready to be linked to the Bluemix
  1. 1.
    On Github from this newly created project go to Settings
  2. 2.
    On the left sidenav there will be Integrations&Services. Click it
  3. 3.
    Click ‘Add Service’ and search for IBM Bluemix DevOps Services
  4. 4.
    In the prompt form enter Bluemix credentials and click Add
  5. 5.
    On the Bluemix go to DevOps Services and click Create a Project
  6. 6.
    Click Link To An Existing Repository
  7. 7.
    Log in to GitHub if prompted
  8. 8.
    Select a repository from the dropdown

Set up Continuous Integration

  1. 1.
    In the top Right Corner of your project inside DevOpsServices click on Build&Deploy button
  2. 2.
    Click Add Stage
  3. 3.
    Click Jobs
  4. 4.
    Click Add Jobs and select from the dropdown
If Build&Deploy picked and the checkbox for auto pick up was selected now the repo should be connected to the bluemix and every time the commit is made and pushed to GitHub it will be pushed into the bluemix as well and build&deploy actions will be triggered automatically.

Configure multiple environment credentials access with VCAP_SERVICES

Bluemix services require a user to use credentials assigned to him/her by the Bluemix. The hard coded version is needed to run your application locally. But the hard coded version is not a good idea if the app is to be hosted in different places including GitHub. The Bluemix offers you to set up the configuration to use environmental variables they host. VCAP_SERVICES help us to leverage this functionality to manage Bluemix services credentials on the appication side.
It can be done on the server side in the file corresponding to the environmental configuration parameters.
Please follow the example of configuring the document_conversion services:
var document_conversion = {};
if (process.env.VCAP_SERVICES) {
var services = JSON.parse(process.env.VCAP_SERVICES),
for (svcName in services) {
if (svcName.match(/^document_conversion/)) {
document_conversion = services[svcName][0]['credentials'];
// NOTE: the parameters after the || are for running the app locally
module.exports = {
PORT: process.env.VCAP_APP_PORT || '<yourPortNumber>',
'document_conversion': {
'username': document_conversion.username || '<your username>',
'password': document_conversion.password || '<your password>'
The next step would be simply to require the service and the configuration in your Node file and pull data for the service you need:
var DocumentConversionV1 = require('watson-developer-cloud/document-conversion/v1'),
config = require('<path_to_config_folder>')
documentConversion = new DocumentConversionV1({
username: config.BLUEMIX_SERVICE_CREDENTIALS.document_conversion.username,
password: config.BLUEMIX_SERVICE_CREDENTIALS.document_conversion.password,
version_date: '2015-12-01'
This will allow you to configure multiple Bluemix services in the centralized manner and to access the credentials easily from any Node file.