Last month, we launched a partnership with CloudBees, the company behind the popular open source Jenkins Continuous Integration tool chain. Continuous integration and delivery are at the heart of the way we make software at Pivotal, and Jenkins makes us agile—allowing for quick iterations while delivering high quality software to our customers. This is why Jenkins is one of our favorite CI tools, and it is now available as a turnkey add-on service for Pivotal CF. You can download it from the Pivotal Network.
The Jenkins Enterprise service is deployed via Ops Manager with minimal configuration. Ops Manager simplifies the process of installing and configuring Jenkins, including the setup of master and slave node, registration of a trial licence, setup of additional useful developer plugins, and integration with Cloud Foundry’s User Authorization and Authentication (UAA) service. With single sign on (SSO), developers can also log in with existing credentials.
Jenkins infrastructure can easily be scaled up and down or re-deployed straight from Ops Manager. The flexibility of the Cloud Foundry platform applies to partner services as well.
Integrating with Pivotal Cloud Foundry
The features that I am most proud of put the application developer experience at the centre of the product, ensuring a consistent development, testing, and staging experience.
We mimic the runtime environment for Ruby and NodeJS applications, and we allow you to provision and bind to service instances such as your database. The approach enables integration testing and allows for direct deployment from Jenkins into your chosen Pivotal CF environment.
How Does It Work?
Visit your CloudBees Jenkins installation at http://pivotal-cloudbees.your-cf-installation.com and click on New Item. Then choose the “Build a free-style software project” to get started.
Using an example Ruby and Redis test application from GitHub, you can run the test suite for this application, and provision a Redis instance on your Pivotal CF installation.
Next, create a build step to Execute Shell commands.
Type in the following code.
It is important to understand and walk through this code block, section by section:
Using Buildpacks and Data Services
. cf_buildpack export REQUIRED_SERVICE_INSTANCES=’p-redis:development:redis’ . test_service_instances rspec
The first line tells Jenkins to use the same Ruby build pack to run your application during the tests as would be used in the runtime environment, helping to ensure consistency.
The second line exports the data service and plan you would like to use. Here, we are using the `p-redis` product, with the `development` plan and we are going to refer to it as `redis`.
The third line provisions an instance of the Redis development plan to be used during your tests and binds your application to it. The last line runs the Rspec test suite provided in the GitHub repo.
Targeting Your PCF Environment
cf api https://api.your-cf-installation.com --skip-ssl-validation cf login -u me -p password -o development -s development
The first line targets the Cloud Foundry CLI to your Pivotal CF environment. For example, this is your production application where you wish to deploy your app after a successful test run.
The second line authenticates with your username and password and chooses the development organisation and space.
Pushing Your Application
cf create-service p-redis development redis cf push redis-example-app —no-start cf bind-service redis-example-app redis cf restart redis-example-app
The first line creates a service instance of Redis in your deployment environment, called
The second line will push your application with the name `redis-example-app` and does not start it yet.
The third line binds your `redis` instance to your application, and the last line restarts your application so it can utilise this binding information.
That is how easy it is to use Jenkins to pull an application from your GitHub repo, use buildpacks, create test data service instances, log in to your deployment Pivotal CF environment, and push the app live!
About the Author