IBM Bluemix: Hello World with Sinatra and Dev Ops.

12
Bluemix Hands-On Workshop Hello World with Ruby Sinatra and DevOps Services Version : 3.00 Last modification date : 07/26/2014 Owner : IBM Ecosystem Development

Transcript of IBM Bluemix: Hello World with Sinatra and Dev Ops.

Bluemix Hands-On Workshop

Hello World with Ruby Sinatra and DevOps Services Version : 3.00 Last modification date : 07/26/2014 Owner : IBM Ecosystem Development

Copyright IBM Corporation 2013-2014. All rights reserved. 3

Table of Contents

Introduction ................................................................................................................................................ 5

Step 1 Log into Bluemix ................................................................................................................................ 5

Step 2 A Quick introduction to DevOps Services .......................................................................................... 8

Step 3 Run the code in Bluemix .................................................................................................................. 11

Copyright IBM Corporation 2013-2014. All rights reserved. 5

Lab Objectives:

This lab builds on the previous lab. Rather than download the source and project files from Bluemix to our hard drive,

we will store them in IBM’s cloud-based team development environment DevOps Services https://hub.jazz.net/.

DevOps Services is tightly integrated with the Git distributed revision control and source code management (SCM)

system as well as with GitHub https://github.com/, a web-based hosting service which provides a web-based

graphical interface and desktop as well as mobile integration. http://en.wikipedia.org/wiki/GitHub

We will download an entire project from Bluemix to DevOps Services

There we will modify the code, and deploy the updated version back to Bluemix.

Team collaboration as well as DevOps functionality is fully supported in Dev Ops Services and it is easy to

fork existing projects.

This lab will give a brief overview of DevOps Services, with pointers to where we can get more in-depth

information.

For an introduction to DevOps Services, use this URL: https://hub.jazz.net/tutorials

Lab Duration : 40 minutes

Introduction

This lab builds on the previous lab, Hello World with Ruby Sinatra, and shows how to use DevOps Services to manage and update a simple Sinatra application that runs on IBM BlueMix. We will re-use our existing Ruby Sinatra app, but instead of downloading it to our local drive we will load it into IBM’s team development environment DevOps Services. Then make a change to a source file, and push the project back to Bluemix. The same pattern, but now tailored for team development. Let’s begin by going through the major features of DevOps Services on this link: https://hub.jazz.net/features After we have read through the features, let’s get started using DevOps Services.

Step 1 Log into Bluemix Let’s get started:

Step 1 Go to https://hub.jazz.net/ to create free account.

Step 2 Go to https://ace.ng.bluemix.net

Step 3 Log into Bluemix

Copyright IBM Corporation 2013-2014. All rights reserved. 6

Figure 1 Bluemix login screen

Step 4 After Logging in, click on the Ruby runtime we created in the previous lab.

Step 5 We will recognize the Route which is the URL of the app and to the right of this we see ADD GIT.

Step 6 We will click on ADD GIT, shown in the red oval above. What we are doing is to

save the source code of the Sinatra app to a DevOps servi es project instead of to our hard drive.

Step 7 Note: IBM DevOps services supports three types of code repositories. Jazz SCM, Git and GitHub https://hub.jazz.net/create. Currently the only repository supported from Bluemix is Git.

Copyright IBM Corporation 2013-2014. All rights reserved. 7

Step 8 We then select Populate the Git repository with the started application package and

deploy it in the application.

a. If we do not select Populate the Git repository, we will get a skeleton project in DevOps, without any Ruby code.

b. However, if we select Populate the Git repository with the starter application package we will not get any additions that we may have added to the starter package. As when we changed the hi.haml file in the first lab.

c. However, when we begin to push changes made in Dev Ops Services, this limitation will go away.

Step 9 Click on Continue

Figure 2 Git Repository created

Step 10 We will see the message in green above Success… Click on Close

Copyright IBM Corporation 2013-2014. All rights reserved. 8

Figure 3 Click on the red oval Code link to access your DevOps repository

Step 11 If we now look at the Bluemix screen we will see a GIT URL and to the right of that a CODE link. This is a sign that the connection to Dev Ops Services has been created.

Step 12 Click on this link to be switched to the DevOps screen.

Step 2 A Quick introduction to DevOps Services

Figure 4 The Sinatra environment in DevOps

Step 1 We now have our project in the DevOps Services cloud-based environment.

Step 2 At the top right corner of the screen, we see three tabs:

a. Edit, where we will edit and change or code to then deploy it back to Bluemix.

b. Track & Plan which is an Agile tool that makes viewing, editing, and planning tasks fast and easy. Track work for you and your team, quickly create new defects and check what's incoming to your project. Take a look at this tab and the functionality, although we will not be using it this time.

c. Build & Deploy which allows you to manage the deployment of your project and includes the auto-deploy feature.

Copyright IBM Corporation 2013-2014. All rights reserved. 9

Figure 5 DevOps menus

Step 3 If we click on Edit in the upper right-hand corner of the screen, we see two sets of menus, both in the right-hand side of the sceen.Fork, Deploy and Deploy As allow us to

a. Fork or copy the entire project into a project of our own, where we can modify it at will

b. Deploy the project to Bluemix, or

c. Deploy it to Bluemix with certain parameters

Step 4 In the right-hand corner is a second set of icons, much smaller, but very important. By hovering over them we can see their functionality

a. The top one is Edit.

b. The second one from the top is called Git Respository and it is exstremely important We use this to commit updates and changes to the code base of the repository, provided we are using an underlying Git Repository.

c. A second option is to use the Jazz SCM format as an underlying code repository.In that case this button will be invoking Jazz SCM .

d. For this exercise it is sufficient to use the Deploy icon at the top of the screen to deploy to Bluemix. But for team use it is important to learn the additional functionality.

Step 5 Now let’s make a change to the hi.haml file, just as we did in the first lab.

Copyright IBM Corporation 2013-2014. All rights reserved. 10

Figure 6 Opening the hi.haml file in DevOps

Step 6 We will now expand the project in the left-hand pane and open the View folder.

Step 7 In the View folder we find the hi.haml file. Haml (HTML Abstraction Markup Language) is a lightweight markup language that is used to describe the XHTML of any web document without the use of traditional inline coding. It’s designed to address many of the flaws in traditional templating engines, as well as making markup as elegant as it can be http://en.wikipedia.org/wiki/Haml

Step 8 We will make a simple change to the HTML code in the HAML file. The changes are saved automatically in DevOps Services.

Figure 7 Click on Deploy will re-deploy our code to Bluemix

Step 9 We are now ready to deploy our changes to Bluemix, by clicking on the Deploy button. Note: We can also click on the Deploy As button to change the organization and Space parameters.

Copyright IBM Corporation 2013-2014. All rights reserved. 11

Figure 8 Ready to deploy the changed code to Bluemix

Step 10 We accept the default values for Organization and Space and click Deploy. Organization and Space are Bluemix concepts. Organization is your company or department while Space is used to separate your development into for example: dev, test and ops.

Figure 9 Clickable link appears in status message

Step 11 During the deployment phase a message will appear with information. After a short while a clickable link will appear in the right-hand side of the green status message. We will click on that link to get back to Bluemix.

Figure 10 Back in Bluemix

Step 12 We now click on the Route to see the app and the changes we have made.

Step 3 Run the code in Bluemix

Copyright IBM Corporation 2013-2014. All rights reserved. 12

Figure 11 Output from the modified app

Step 13 Here we can see the new output from the app. Step 14 Although we have only scratched the surface of the rich set of functions available with

DevOps Services, we have shown how easy it is to integrate DevOps Services and Bluemix.

The main reason for using DevOps Services, apart from the fact that it is a cloud-based repository and therefore available wherever we are, as well as backed up, is that it makes team development easy.

We recommend the following free e-book for anyone who intends to use DevOps Services and do team development with Bluemix. https://jazz.net/blog/index.php/2013/10/31/devops-for-dummies-now-available/

And this concludes this lab. The main take-away of this lab is the importance of learning DevOps Services for serious cloud development. Now on to the next lab.