We’re giving away 1,500 DJI Tello drones. Enter to win ›
By Doug Tidwell | Published November 20, 2017 - Updated November 20, 2017
Try IBM Cloud for free
Build your next app quickly and easily with IBM Cloud Lite. Your free account never expires, and you get 256 MB of Cloud Foundry runtime memory, plus 2 GB with Kubernetes Clusters. Get all the details and find out how to get started. And if you’re new to IBM Cloud, check out the IBM Cloud Essentials course.
IBM Developer code patterns are complete projects that include git repos to get you started with various technologies. This tutorial shows you how to take a cloned git repo and tie it to the delivery pipeline for your own app running in IBM Cloud. We’ll go through a complete example, starting with a new Cloud Foundry app and then cloning a git repo. Next, we’ll configure the cloned repo to work with the new app, and wrap things up by making sure any change that’s pushed to the cloud from the cloned repo automatically triggers the delivery pipeline of the app.
We’ll start by setting up a new app at the IBM Cloud console. Go to the console and click the Create button to create a Cloud Foundry app:
When the catalog appears, click Cloud Foundry Apps in the list on the left:
Our example app is a node app, so click SDK for Node.js in the middle of the screen:
Give your app a name:
Next, click the Create button in the lower right-hand corner of the screen. As always, your app name has to be unique across the IBM Cloud. You’ll get an error message if the name you choose already exists.
In a minute or two, you’ll see the Getting Started page:
Notice that there’s a spinning circle next to the word “Starting” in the upper right. The Visit App URL link is disabled for now. When your app is deployed, you’ll see a solid green circle, the status “Running,” and the Visit App URL link will be active.
That’s all you need to do to create your new app. Now it’s time to set up a git repo for the app. This requires a continuous delivery toolchain. That’s what comes next.
To get started, click the Overview tab on the left:
Scroll down to the bottom and click the Enable button in the Continuous delivery box:
On the continuous delivery toolchain page, scroll down to the bottom. Make sure you specify that this is a new repo:
Take the defaults for everything else, click Create, and the cloud side of things will be all set up. You should see the Toolchain page:
To tie your local repo to the cloud, you need to get the URL of the repo you just created. Under Code, open the Git box (in the middle of the Toolchain page) in a new browser tab:
In the tab that opens, you see the details of the repo:
In the middle of the page, copy the HTTPS URL of the repo. (You need to click select HTTPS instead of SSL.) When the URL appears, click the Copy icon:
To watch everything work, open the delivery pipeline page for demonstration purposes. When you do a git push later, the delivery pipeline page will show you what’s happening as your updated code goes through the build and deploy stages. Click on the Delivery Pipeline tile to open the page:
You see the status for the build and deploy stages:
Finally, go back to the Getting Started page and click Visit App URL at the top:
You see this scintillating page:
Before you leave the cloud, here’s where things stand:
Let’s return to your local machine to start cloning the repo. For this example, clone https://github.com/IBM/dWSimpleApp:
Note: when you clone this repo, be sure to read all the Terms and Conditions in the README file.
Clone the repo and change to the directory that contains the cloned code:
Now you need to point the cloned repo to the app in your IBM Cloud account. Otherwise, any changes you try to push will go back to the original repo. Here are the commands:
git remote remove origin
git remote add origin
git push -u origin --all
git push -u origin --tags
Your results should look something like this:
Note: This last command isn’t necessary if the git repo you cloned doesn’t have any tags, but it’s included here for completeness. If you don’t have any tags, running this command won’t make any difference.
Everything should be all set up now. To make sure everything works, edit the index.html file in the cloned repo on your machine. To make things obvious, change the heading on the page:
After saving the updated file, do the usual git add, git commit, and git push sequence:
Within seconds of the git push, the build stage of the delivery pipeline should be running in the browser:
Notice that the comment from the git commit command shows up in the UI. If the build stage completes successfully, the toolchain moves on to the deploy stage:
When deployment is done, you can click on the URL of the app and see your changes:
The goal of all the sample code we have at IBM Developer is to help you build the next great app. Git repos are great ways to package code, but by default they stay tied to their original source when you clone them. Using the techniques in this tutorial, you can clone any git repo you like and connect it to the continuous delivery toolchain of an app running in the IBM Cloud.
February 8, 2019
March 29, 2019
December 13, 2018
Back to top