Continuous Delivery for Java with CloudBees Jenkins Enterprise

Note: CloudBees Jenkins Platform for PCF is deprecated, and no further development will be made against this tile.

Introduction

This is a guide using CloudBees Jenkins Enterprise for Pivotal Cloud Foundry (PCF) and integrate with your Cloud Foundry installation.

This guide covers the following topics:

  1. Cloning an application from Github
  2. Building your Java application
  3. Pushing your application to Cloud Foundry Elastic Runtime

Create the Initial Build Job

  • Navigate to the Jenkins Home and access the folder belonging to your user or organization.

  • Click new item, give it a name, and select Build a Maven project. Click OK.

  • Under Source Code Management, select Git, and supply your repository URL and credentials. This guide uses the Spring PetClinic Application as an example. You can find the Spring PetClinic Application at https://github.com/CloudBees-community/spring-petclinic.git

Cd cf github

  • Under Build Triggers, select Build when a change is pushed to GitHub.

  • Under Build Environment, check Set up Cloud Foundry CLI.

    • API EndPoint: Use api.your-cf-installation.example.com/
    • Skip SSL Validation: Check this.
    • API Credentials: Select your PCF/UAA Credentials. Note that Cloud Foundry CLI credentials can only be configured at the folder-level. See the credentials section of this topic for more details.
    • Organization: Use the organization that you belong to on PCF.
    • Space: Use the space in your organization where you want to deploy the application.

cf CLI Configuration Section

Cd cf cli

  • In the Build section, insert package as goal.

  • Under Post Steps, add an Execute Shell post-build step and insert cf push APP-NAME -p PATH-TO-APP. Replace APP-NAME with the name of your application. Replace PATH-TO-APP with the local path to your application, including the application itself. In our example, we use insert the following: cf push petclinic -p target/petclinic.war

Cd cf build

  • Save the configuration. Click “Build Now” to run the build.

Managing the Deployed Application

After executing the job, the application is deployed in your Elastic Runtime environment (https://console.your-cf-installation.example.com/), in the organization and space that you defined in the cf CLI configuration section of this topic.

Elastic Runtime Console

Cd cf elastic 1

From the Pivotal Cloud Foundry Elastic Runtime Console Page, you can scale, manage, and monitor your application.

Cd cf elastic

Github Set Up

Both the Github plugin and git are already installed in your Jenkins instance. You must only specify the URL of the project that you want to build and deploy, and the GitHub credentials to use, if any. For our example, no GitHub credentials are needed.

Note: You can only specify credentials at the folder level.

Credentials Set Up

Only Administrators can create global credentials. For this reason, the Add Credentials Button in the job configuration page is disabled to users. A user can still create credentials at the folder level, for example, in any of the job parent folders. Follow the step below to create credentials at the folder level:

Only Administrators have the permission to create global credentials. For this reason, in the job configuration page (when setting up the i.e. git project, CF CLI, …) the Add Credentials Button is disabled to the user. However, a non-administration user can still create credentials at folder level i.e. in any of the job parent folder. The procedure is quite straightforward:

  • Access the folder where you want to configure the credentials (i.e. CloudBees folder) and click on Configure

Folder configuration

  • In the Credentials section, click Add Credentials, and configure the desired credentials.

Folder credentials

The credentials that you configure at this level are accessible by all of the jobs created in any of the child-folders of the current one.

Was this helpful?
What can we do to improve?
Create a pull request or raise an issue on the source for this page in GitHub