Thursday, 18 June 2015

Build a Cloud Foundry Java Appllcation: IBM Bluemix DevOps Services!

In the previous posting I created an java application in Cloud Foundry that I already prepared (built and packaged) locally beforehand. A good PaaS would allow me to edit, build and deploy right from the platform itself. With some technologies, like Node.js, this is very easy as the files do not need to be compiled but as we also wish to show some build integrations so we'll continue with Java.

IBM BlueMix provides these edit, build and deploy SaaS capabilities called IBM Bluemix DevOps Services. It provides integrated source code version control (git) , a source code editor (orion), tracking and planning and build and deploy services. The deploy stage can deploy into the Cloud Foundry upon code change in source code repository.

There are other ways to do this in an automated fashion outside of IBM Bluemix, build processes can be on local bare metal servers or using IaaS with IBM UrbanCode Deploy. I'll will cover how to use IBM UrbanCode in later postings where I use BlueMix IaaS to set up my build environment.

In the meantime, I am going to set up IBM Bluemix DevOps services to build our sample java application.
  1. To add a git repository to our new application, in Bluemix we navigate to the boriscloud application from the Bluemix dashboard
  2. And click the "Add GIT" button:
  3. Continue through the dialogues that pop up, after which a new git repository link should be added to the project.
  4. Now we can connect to the git repository using the git command line and add our files

    > git clone https://hub.jazz.net/git/kuschel/boriscloud
    Cloning into 'boriscloud'...
    Username for 'https://hub.jazz.net': <Bluemix username>
    Password for 'https://<Bluemix username>@hub.jazz.net':
    remote: Counting objects: 4, done
    remote: Finding sources: 100% (4/4)
    remote: Total 4 (delta 0), reused 4 (delta 0)
    Unpacking objects: 100% (4/4), done.
    Checking connectivity... done.
    
    
  5. Set the remote repository URL for push/pull

     > git remote set-url origin https://hub.jazz.net/git/kuschel/boriscloud
    
    
  6. Commit the boriscloud war source code

    > git commit
    [master cdb0a4d] Initial Commit
     6 files changed, 130 insertions(+), 1 deletion(-)
     create mode 100644 BorisCloud.war
     delete mode 100644 License.txt
     create mode 100644 WebContent/META-INF/MANIFEST.MF
     create mode 100644 build.xml
     create mode 100644 manifest.yml
     create mode 100644 src/com/boriskuschel/cloud/SampleServlet.java
    
    
  7. Push the changes to Bluemix

    > git push
    Username for 'https://hub.jazz.net': <Bluemix username>
    Password for 'https://<Bluemix username>@hub.jazz.net':
    Counting objects: 2, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (2/2), 353 bytes | 0 bytes/s, done.
    Total 2 (delta 1), reused 0 (delta 0)
    remote: Resolving deltas: 100% (1/1)
    remote:
    remote: Processing changes: refs: 1, done   
    To https://hub.jazz.net/git/kuschel/boriscloud
       cdb0a4d..c6b8136  master -> master
    
    
  8. To merge the local repository and changes that were committed to the Bluemix Git using it's git editor:

    > git pull
    Username for 'https://hub.jazz.net': <Bluemix username>
    Password for 'https://<Bluemix username>@hub.jazz.net':
    remote: Counting objects: 9, done
    remote: Finding sources: 100% (7/7)
    remote: Total 7 (delta 1), reused 7 (delta 1)
    Unpacking objects: 100% (7/7), done.
    From https://hub.jazz.net/git/kuschel/boriscloud
       c6b8136..d42dd0d  master     -> origin/master
    Merge made by the 'recursive' strategy.
     .cfignore    | 2 ++
     .gitignore   | 1 +
     project.json | 1 +
     3 files changed, 4 insertions(+)
     create mode 100644 .cfignore
     create mode 100644 .gitignore
     create mode 100644 project.json
    
    
  9. To get to the git editor click the "Edit code" button. Form here you can edit files, commit them and most of the common git operations.

  10. Press the second icon on the left bar to get to the git operations view, press the "sync" button to merge the local repository with any incoming changes that were committed using "git push" command.
  11. Once all the files have been added a corresponding build.xml file was also added. This will be used from the build. Click on the "Build & Deploy" button.
  12. Click on the build state. By default, the build will occur whenever new changes are pushed to git.

  13. Configure the Build Stage to use ant and the build.xml file.

  14. Set the Deploy Stage to deploy to cloud foundry.

  15. After the build and deploy is completed it should look like this:

That's it, how we have a slick DevOps operation for our sample java application.

3 comments:

  1. Great Article
    Cloud Computing Projects


    Networking Projects

    Final Year Projects for CSE


    JavaScript Training in Chennai

    JavaScript Training in Chennai

    The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

    ReplyDelete
  2. Nice Information Your first-class knowledge of this great job can become a suitable foundation for these people. I did some research on the subject and found that almost everyone will agree with your blog.
    Cyber Security Course in Bangalore

    ReplyDelete