Deploying to IBM Cloud Foundry

2 minute read

You can find a sample repo for deploying to IBM Cloud with CloudBees CodeShip Pro on GitHub here.

Continuous Delivery To IBM Cloud Foundry

To make it easy for you to deploy your application to IBM Cloud Foundry, we’ve built deployment images that have the IBM Cloud CLI installed and configured for use in the CI/CD process.

You will simply need to add one of the IBM deployment images as a service in your codeship-services.yml file so that you can run the commands you need.

IBM Cloud Deployment Container


Prior to getting started, please ensure you have the following:


To deploy to IBM, you will need to add authentication credentials to your encrypted environment variables, which you will encrypt and include in your codeship-services.yml file.

For the example deployment in this documentation, we will add the following:






These variables will be set on the IBM deployment container, which you can read more about below. This deployment container will use the environment variables as part of the authentication required by the IBM Cloud CLI when you run your deployment commands.

You can name these variables anything you’d like depending on the specifics of your scripts, and different configurations may not require all of them to be used.

Configuring Deployment Service

Once you have created your encrypted environment variables, you will want to add a new service to your codeship-services.yml file.

This file will use the image CodeShip maintains for IBM-based deployments, and will read your code from a volume connected to your primary service.

This service will be used for all of your Cloud Foundry deployment commands, and will use the encrypted environment variables you created above.

app: build: image: your-org/your-app path: . dockerfile_path: encrypted_env_file: - ibm.env.encrypted volumes: - ./deployment/tests:/tests deployment: image: codeship/ibm-bluemix-deployment encrypted_env_file: - ibm.env.encrypted volumes: - ./deployment/tests:/tests

Deploying Your App

Once you have added the deployment service to your codeship-services.yml file, you will now run Cloud Foundry deployment commands from your codeship-steps.yml file using that service to execute the commands.

Note that in this example, all of the Cloud Foundry deployment commands have been moved to a script file named

- name: Cloud Foundry Deployment service: deployment command: /tests/

Inside the script, you will have something similar to:

#!/bin/bash set -e # login to IBM Cloud via credentials provided via (encrypted) environment # variables bluemix login \ --apikey "${BLUEMIX_API_KEY}" \ -a "${BLUEMIX_API_ENDPOINT}" \ -o "${BLUEMIX_ORGANIZATION}" \ -s "${BLUEMIX_SPACE}" # check that the CloudFoundry CLI is available via the IBM Cloud CLI wrapper bluemix cf version # list available CloudFoundry applications bluemix cf apps # push the application bluemix cf push

Note that the specifics of your deployment scripts may vary depending on what you are trying to do, and the above is intended only as an example and a starting place.