- Fork an existing DevOps Services project
- Manually deploy your application to Bluemix
- Update your application and redeploy it manually
- Enable auto-deployment for your project
- Trigger automatic deployment when a change is pushed to source control
Time requiredThis lab takes approximately 15 minutes to complete.
Before you beginFirst, before you start the Â lab, you must register for IBM Bluemix DevOps Services at: https://hub.jazz.net.
After you have registered and received your IBM ID through email, or if you already have an IBM ID, you can start the lab. Â If you see references to an IBM Bluemix account, you should use your IBM ID for that account.
Create a DevOps Services projectIn this tutorial, you start by forking a sample project. When you fork a project, you create a new DevOps Services project that has a copy of the code in the project that you forked.
Fork the DevOps ServicesÂ projectTo fork an IDS project, complete the following steps:
- Open spirit | Sentiment Analysis App.
- You can explore the project before deciding to fork it.
- Click FORK PROJECT to copy the code into a new project.
- In the Fork Project window, enter a unique project name, your Bluemix space information, and click CREATE. The forking process might take a few minutes depending on the size of the project.Â When you fork the project, a Git repository hosted at DevOps Services is created for your project and a copy of the code in the original project is automatically pushed to your new projectâ€™s repository.
- When the project is forked, click EDIT CODE to begin working with the code.
Configure your applicationYou now have a fork of the Sentiment Analysis App. Â In order for the app to run successfully, youâ€™ll need to update the application so it has Twitter keys. Â Â
- By default, the readme.md will be displayed in the right pane. Â Scroll down until you see the section, â€śTo get your own Twitter Application Keys.â€ť Follow the instructions to get Twitter keys. You will need to sign in to your Twitter account.Â
- Configure your application â€śapp.jsâ€ť file with the following values from your Twitter application:Â
- consumer_key is the Twitter â€śConsumer keyâ€ť
- consumer_secret is the Twitter â€śConsumer secretâ€ť
- access_token_key is the Twitter â€śAccess tokenâ€ť
- access_token_secret is the Twitter â€śAccess token secretâ€ť
- Save your changes to app.js by selecting File > Save in the online editor.
Pushing your application to BluemixYou now have a fork of the Sentiment Analysis App and can deploy it to Bluemix. Â Behind the scenes, deploying the application translates into bundling up the project artifacts, creating an application at Bluemix, transferring the bundled application to Bluemix, and starting the application. Â Bluemix application names and URLs are created using properties, which are often defined in the manifest.yml file in a project. Â You forked an existing project that has the properties are already setup for you in a manifest.yml. To deploy your application to Bluemix manually, complete the following steps:
- Expand the Run bar at the top of the editor area and click the Plus icon (+).Â
- In the Edit Launch Configuration window, select where you would like the application to deploy. The default values are fine, as in your email as the organization and â€śdevâ€ť as the space. Click SAVE.
- Next to the Run bar, click the Deploy icon.
When the application has finished deploying to Bluemix, the grey circle icon turns green to indicate that the application was successfully deployed to Bluemix.
- Next to the Run bar, click the Open application icon. The application opens in a new browser tab or window.
- In the application, type a subject such as â€śJustin Bieberâ€ť and click Go.
- Watch as the application analyzes the Twitterverseâ€™s reactions to your topic.
- Near the Run bar, click the Open application dashboard icon.
- The application settings page at Bluemix will be displayed. Look around and youâ€™ll find detailed status on the application like how much memory is in use.
Optional: Update your applicationYou might want to try updating your application and pushing the changes to Bluemix. Â This will give you time to explore the DevOps Services editor a bit. Â The editor has quite a few keyboard shortcuts, and you can see the complete list in the Help menu when you are in the DevOps Services editor.
- In the DevOps Services editor, click app.js to open it.Â
- Use the â€śFindâ€ť keyboard shortcut (CTRL+F or CMD+F) to find the word â€śWelcomeâ€ť and change some text in the HTML tags to something else.
- Use the â€śSaveâ€ť keyboard shortcut (CTRL+S or CMD+S) to save your change.
- Press the Play icon next to the Run bar again to update your application running at Bluemix.
Optional: Â Turning on auto-deployment for your projectEarlier in this lab, you manually pushed your application to Bluemix when you pressed the Deploy button next to the Run bar. Â Another option is to automatically deploy your application to Bluemix every time that you push to your projectâ€™s source control in Git.Â To enable auto-deployment, complete the following steps:
- Click BUILD & DEPLOY.
- Click Add stage.
- Rename the stage Auto deploy the Sentiment Analysis Project.
- In the Input tab, select the following options:
- For the Input type, select SCM Repository.
- For the Git URL, you can leave the default URL to your Git repository.
- For the Branch, select master.
- For the Stage trigger, select Automatically execute jobs when a change is pushed to Git.
- In the Jobs tab, click ADD JOB.
- Select Deploy.
- Leave the default values and click SAVE.
Make a change and push itLetâ€™s make another trivial change and push it to your repository, so we can see the auto-deployment in action. Â
- In the DevOps Services editor, open the app.js file.
- Change something trivial within the HTML tags and save the changes.
- In the left navigation bar, click the Git Repository icon.Â
- The file with the pending change will be displayed:
- Your change is now ready to commit. Â Select the changed file and enter a description of the change.
- Click Commit.Â
- The change is in the Outgoing section and still needs to be pushed to your Git repository, so click Push. Â The change will be pushed, and the page will update to show no more pending changes. Â For more information about pushing changes, see the open source documentation for Orion.
- Open your auto-deployment status page by clicking BUILD & DEPLOY. You will see the job status, the last commit message, and the deployment status.Â
- When the deployment completes, open your application again to verify the auto-deployed changes.
Optional: Bluemix Live SyncWith node.js apps, you can make changes to static files, like HTML or CSS, and have them immediately included in the deployed app by using the Bluemix Live Sync feature. You can also edit code, however, you must click the Restart icon to have those changes reflected in the deployed app.
- Verify that the app is running.
- Toggle the Live Edit switch to the on position.Â
The app redeploys. When the redeploy is finished, the Live Edit mode is enabled and confirmed in the Run bar.
- Edit a file and save the changes.Â
- If you edited code, such as app.js or server.js, click the Restart icon.
- Refresh the app in the browser. Changes to static files, like HTML and CSS files, are reflected in the deployed app momentarily.
- Optional: Use the debug tools to troubleshoot issues.
- Click the Debug icon.
- Click Open Debugger. The file opens in a new browser tab or window where you can work with the code.Â
- Use the debugging tools to create breakpoints and inspect Â variables in your code to isolate problem areas as you work.
SummaryThis lab described how to complete the following tasks:
- Create a DevOps Services project by forking an existing project
- Push an application to Bluemix manually and automatically
- Manage your application on Bluemix
Additional resourcesFor more information on the inspiration for the Simple Sentiment Analysis application and how it was developed, view the developerWorks article Build a sentiment analysis application with Node.js, Express, sentiment, and ntwitter.
Have questions?Â Ask us (almost) anything in our forum.
Looking for more tutorials?Â Check these out:
- Getting started with Bluemix and DevOps Services
- Setting up Eclipse Git, and RTC Desktop Clients for use with DevOps Services
- Developing Bluemix applications with Eclipse and DevOps Services
- Developing Bluemix applications with the Web IDE
Prefer video?Â Youâ€™ll love these:
- Whiteboard Video:Â Using JazzHub to Deploy Applications to the Cloud
- Whiteboard Video:Â Developing in the Cloud, for the Cloud
- Webinar:Â Develop and Deploy Software in the Cloud with JazzHub
- Webinar:Â Code in the Cloud with JazzHub:Â DevOps Services for IBM Cloud Platform
Get social with us!