Developing Bluemix apps in Java with Eclipse and Bluemix DevOps Services

Last modified: 24 March 2015

Time: 30 minutes

Follow the steps in this tutorial to develop a Java™ application by using IBM® Bluemix™, IBM® Bluemix™ DevOps Services, and the Rational Team Concert™ client for Eclipse.


Learning objectives

  • Create your own version of a DevOps Services project by forking it to your space.
  • Create build and deployment stages by using the Build & Deploy feature.
  • Open the project in Rational Team Concert.
  • Make a code update and push it to the project repository by using Rational Team Concert.
  • Verify automatic builds.
  • Make a code update that causes a build failure to see how the build results look.

Before you begin

  1. Make sure that your IBM id is registered with Bluemix.
  2. Log in to DevOps Services by using your IBM id.

Fork a sample project

To quickly get started developing in Java, you fork a sample project named WordCounter. WordCounter uses Jazz™ source control management (SCM) and contains a manifest for deploying to Bluemix. You can load the project directly in the Rational Team Concert client for Eclipse. To explore the project before you fork it, see the WordCounter project page.

DevOps Services also supports Git projects. For more information, see Getting Started with Bluemix and Bluemix DevOps Services using Java.

On the WordCounter project Overview page, click FORK PROJECT. Click Fork Project

When you are prompted, enter a unique name for your project. Then, click CREATE. Create Project Dialog

A new project is created with a copy of the code from the sample project.

Tip: If you see an error message, make sure you have a Bluemix account.

You're ready to build and deploy.


Deploy your app

  1. Click BUILD & DEPLOY.

    • When you build and deploy, your Bluemix account might be charged. For more information, see the Bluemix Pricing page. To track charges, after you deploy your first build, add the Delivery Pipeline service to your Bluemix space.
  2. On the Pipeline page, click ADD STAGE. The Stage Configuration page opens. Click Add A Builder

  3. Create a stage to build your app:

    1. Click the default MyStage name and change the name of this stage to Build.
    2. On the INPUT tab, use the default settings. Be sure to enter the password for your IBM id where indicated.
    3. On the JOBS tab, click ADD JOB. Select Build and the select the Ant builder type.
    4. In the Working Directory field, type the name of the folder that contains your code; for example, WordCounter. When the project is loaded in the Rational Team Concert client, this folder maps to an Eclipse project automatically.
    5. In the Build Archive Directory field, type the name of the directory where the build output files are archived as part of the build result.
    6. Select the Enable unit tests check box so that you can run the test cases during a build.
    7. Click Save. Add Builder
  4. Click ADD STAGE. The Stage Configuration page opens. Click Add A New Stage

  5. Create a stage to deploy your app to Bluemix:

    1. Click the default MyStage name and change the name of this stage to Deploy to dev.
    2. On the INPUT tab, use the default settings.
    3. On the JOBS tab, click ADD JOB and then select Deploy. This job will use the settings in the manifest.yml file, which is included as part of the sample project. You can use all of the values as provided, except for the hostname. The hostname is used to define your app's URL and must be unique for each app that is deployed on Bluemix.
    4. Override the host with the -n option in the cf push command, as shown in the following image.
    5. Hint: Use a combination of your username and the date or time to ensure that your route is unique.
    6. Click SAVE. Add Deployer
  6. At the top of the Build stage, click the Play icon to build and deploy your project for the first time. The build process takes a couple of minutes. When you see a green circle, the app is live. Successful Build

  7. Verify that the app is running by clicking the app link. Application


Add the Delivery Pipeline service

Add the Delivery Pipeline service to the app so that you can use the Build & Deploy feature later.

  1. Click the running instance of you app to view it in Bluemix. If prompted, enter your IBM id and password. Bluemix Instance

  2. On the new app's Overview page, click ADD A SERVICE OR API.

  3. Select the DevOps category, then click Delivery Pipeline.

  4. Leave the settings for Space and App as they are. Click CREATE.

The Delivery Pipeline service is added to your Bluemix space.


Access your app from the Rational Team Concert client for Eclipse

From the Rational Team Concert client for Eclipse, connect to your running app.

  1. In the DevOps Services Web IDE, click the project link to go to the project Overview page. Project Link

  2. From this page, get the Jazz repository information. Team Invitation

  3. In the Rational Team Concert client for Eclipse, connect to your project and load the code. For detailed instructions, see Setting up Eclipse, Git, and Rational Team Concert Desktop Clients to access Bluemix DevOps Services.


Deliver your first change

When you're in the Rational Team Concert client for Eclipse, change your code then verify that the change is shown in the running app.

  1. On line 10 of index.html, change the app name. Edit Code

  2. Deliver the change to the Jazz SCM repository:

    a. In the Pending Changes view, check in the change in a new change set. Check In Change

    b. If necessary, you can edit the comment for the change set. Edit Change Set Comment

    c. Deliver the change. Deliver Change Set

  3. In a browser, go to the deployment page. A build is triggered soon and the page is updated automatically. Wait until the app status is green. Successful Build

  4. Click the app link and verify that the app name is updated. Application


Add a test failure

To see what happens when the build fails, add a failure to the JUnit tests.

  1. In the WordCounterFinderTest.java file, on line 26, set this.wcFinder to null. Edit Test Case

  2. In the index.html file, on line 10, change the app name. Edit App Name Again

  3. Deliver the changes. DevOps Services shows a failed build, as you expected. The Build stage could not complete. Only successful builds are deployed automatically. When you click the app link, the app name is not updated. Failed Build

  4. Access the build logs and test results by clicking the build. Click Build


Fix the bug

  1. Revert the code in WordCounterFinderTest.java to its previous state and deliver the change. Fix Test Case

  2. Verify that the build is now green. Successful Build

  3. Verify that the app is running, too. Application


Summary

You finished this tutorial. You are ready to develop Java applications on your own.


Need help? Ask a question in the IBM Bluemix DevOps Services forum. Have feedback? Report a bug or share your idea in the IBM Bluemix DevOps Services project.

© Copyright IBM Corporation 2013, 2015.