Develop a Cloud Foundry app toolchain using IBM BLUMIX


  1. Task 1: Create a toolchain

    1. Open the creation page for the Develop a Cloud Foundry app toolchain by clicking Create toolchain:
      Create toolchain button
      You can also select the Develop a Cloud Foundry app toolchain from the Toolchain templates list.
      Develop a Cloud Foundry app toolchain catalog entry
      Tip: For instructions to navigate to the toolchain templates and select a toolchain to create, see Navigating to the toolchain templates.

    2. On the creation page, review the diagram of the toolchain that you are about to create.
      Develop a Cloud Foundry app toolchain template

    3. Review the default information for the toolchain settings. The toolchain's name identifies it in IBM Cloud.
      Note: The URL to access your application must be unique. By default, the toolchain's name is used in constructing that URL. Make sure that the toolchain's name is unique within IBM Cloud.
      Each toolchain is associated with a specific region and resource group. Use the menus on the page to select the region and resource group where you want the toolchain created. You can have up to 200 toolchains per resource group.
      Region and RG picker
      If you want to switch to a different account, click the Profile avatar icon in the banner and select the account.

    4. Review your Git Repo and Issue Tracking settings and, if needed, change them. Each toolchain comes with a sample app, but you can select another repo to use.
      Note: Access to Git Repos and Issue Tracking repositories is region-specific. Generally, this restriction isn't important, because the Continuous Delivery service manages the relationship between your IBM Cloud login and the repositories. However, if the template for the toolchain that you are trying to create keeps the source code for the application in a private repo in one region, and you are trying to create a toolchain in a different region, then the toolchain is not able to clone the source code into your repository. For more information on how to deal with this special situation see Why can't I create a toolchain from a template that uses a private repo in a different region?
      If you want to use a repo from a different Git provider, after your toolchain is created, see the Change Git provider in a toolchain tutorial.

      Git Repos and Issue Tracking configuration

      • To make this repo a private repo, select the Make this repository private option. Access to private repos must be granted manually.

      • To enable issue tracking for ideas, enhancements, tasks, or bugs, select the Enable Issues checkbox.

      • To track the deployment of code changes by creating tags, labels, and comments on commits, pull requests, and referenced issues, select the Track deployment of code changes checkbox.

    5. Click Delivery Pipeline to configure the pipeline for your toolchain.
      The pipeline uses an IBM Cloud API key that you provide to access cloud services on your behalf. In the IBM Cloud API Key section, you can paste in an API key if you already have one, or you can click Create ⊕, and then click Create again to create one here.
      Create an API key for the Develop a Cloud Foundry app toolchain

      Note: You can improve your security posture by using the IAM UI to create a service ID API key.
      After the API key is provided, the Region, Organization, and Space fields of the Delivery Pipeline section are automatically completed. You can use the arrows on the fields to select among the values that the API key can access.
      Pipeline fields filled in for Cloud Foundry app toolchain
      Note:

      • If no organization or space are displayed, create them on the Cloud Foundry Orgs page.

      • If you clicked Create ⊕, click the eye icon to display the value of the API key. Record the API key so that you can use it later. For more information about API keys and how they are used in IBM Cloud, see Understanding API keys.

    6. Click Create. Several steps run automatically to set up your toolchain:

      • The toolchain is created.

      • The sample repo is cloned into your Git Repos and Issue Tracking account. You now have your own version of the code.

      • The delivery pipeline is created and triggered.

      • The toolchain is associated with your app. When you push changes to the toolchain's repo, the delivery pipeline automatically builds and deploys the app.

    7. After a few moments, your new toolchain's Overview page opens.
      Configured and running Develop a Cloud Foundry app toolchain

    8. Click Delivery Pipeline to see the pipeline running.
      Pipeline stages

      Note: If a pipeline stage fails, you can click the run icon on the stage card to run it again.
      Pipeline run icon

    9. Return to the toolchain's Overview page by clicking the breadcrumb link at the top of the page.
      Return to the toolchain Overview page

    10. You can see the deployed app by clicking the Visit App URL link.
      Visit App URL link

      The running app is displayed.
      Running app

    11. Return to the Toolchains page.
      Toolchains list

      The Toolchains page displays all the toolchains that are in your resource group. For each toolchain, you can see icons that represent the tool integrations that are in that toolchain. From this list, you can rename and delete toolchains.

    12. Click your new toolchain to open its Overview page.

    How easy or difficult was it to create and run the "Hello World" app? 

    Add comments ...

    Start task 2

    Task 2: Modify the code

    In this step, you use the Eclipse Orion Web IDE to modify source code.

    You can use the Web IDE to develop associated apps directly from your browser. You also gain access to features such as code completion, syntax highlighting, and IBM Cloud Live Sync.

    When you open the Web IDE, it clones repos from the toolchain that it hasn't encountered before into your personal cloud workspace. After the cloning is finished, those repos are available for you to work with in the same way that you would work with a local clone on your desktop:

    • When you edit in the Web IDE, your changes are saved to your cloud workspace.

    • When you commit a change by using the integrated git tools in the Web IDE, the change is committed to the active branch in that repo in your workspace.

    • When you push a commit, it is pushed from the repo in your workspace to the remote Git repo (the one in your toolchain).

    Note: The git tools in the Web IDE also provide a "sync" operation, which pulls from the remote repo and pushes any changes in a single step.

    You can also use your Git provider's editor by clicking the Git card on your toolchain's overview page to get to the provider's web UI.

    The most common way to work with your source code is to clone the Git repo to your desktop, and use your favorite local editors and tools. See Setting up local clients to work with Git source control.

    1. On the toolchain's Overview page, click Eclipse Orion Web IDE. The root folder that is shown in the file navigator is the root of the repo that was cloned into your workspace. If you have more than one repository in your toolchain, you see one root folder for each of the clones of those repos.
      Initial Web IDE

    2. In the file navigator, expand the repo for your current toolchain, go to the public folder, and click the index.html file to open it.
      Web IDE file navigator

      Editing a file in the Web IDE

    3. Edit the h1 tag to change the text that the deployed app displays. Your changes are automatically saved.
      Edited file in the Web IDE

    4. Push your changes:
      a. From the Eclipse Orion Web IDE menu, click the Git icon.
      Git icon
      b. In the Working Directory Changes section, type a commit message and make sure that the changed file is selected. You can expand public/index.html to see the changes. The changes are highlighted: the original content is in red and the changed content is in green.
      Commit changes to Git

      c. Click Commit to put the changes in the local master branch.
      d. To push the changes to the origin/master branch, click Push. The origin/master branch is used by the pipeline, which automatically builds and deploys your changes.
      Web IDE Git push

      How easy or difficult was it to commit changes to your local branch and then push them to the origin/master branch?
      Add comments ...

    5. Return to the toolchain's Overview page by clicking the Back to Toolchains arrow.
      Return to the toolchain Overview

    6. Click Delivery Pipeline to watch the stages run in response to your commit.
      Watch the pipeline run

      Note: If a pipeline stage fails, you can click the run icon on the stage card to run it again.
      Pipeline run icon

    7. When the pipeline process is completed, go to your toolchain's Overview page and click the Visit App URL link.
      Visit App URL link

    8. Verify that your changes are visible in the running app.
      Running updated app
      How easy or difficult was it to run the updated "Hello World" app?
      Add comments ...

    Start task 3

    Task 3: Add a stage to the pipeline

    With a delivery pipeline, you can automate the continuous building, testing, and deployment of your apps.

    The Build stage pulls the source code from your repository. It then runs jobs to compile or otherwise process the code to produce artifacts suitable for deployment. Each job runs in its own container. The artifacts are passed to follow-on stages through the build archive directory in the container. By default, this directory is the same as the directory where the source code was checked out. The Simple build job type passes the source code from your repo on as the result without modifying it.

    The Deploy stage contains jobs that deploy the artifacts created by the Build stage. For Cloud Foundry apps, if a manifest file exists in the root folder, it is used to determine which buildpack to use. For more information about pipeline stages, including other types of deploy jobs, see the IBM Cloud Docs.

    1. Click the toolchain's Overview page.
      Configured and running toolchain

    2. Click the Delivery Pipeline tool integration to view the build and deployment activity for your app. The pipeline has two stages: one where your app is built and another where it is deployed. After the pipeline completes its deployment process, the pipeline dashboard shows that both stages completed successfully.
      Executed pipeline

    3. To add a third stage to deploy a test instance of your app, click Add Stage.

    4. Click the stage name, MyStage, and change the name to Deploy Stage - Test.
      New stage

    5. Click the JOBS tab.
      Add a new job to the stage

    6. Click ADD JOB, and then select the Deploy job type.
      New job type

    7. Review the IBM Cloud region to choose the region where your test application will be deployed. Specify an API key. Hint: If you saved the API key that you used in task 1, you can reuse it here. Review the Organization and Space fields. Those values specify where in the region to deploy the test instance of the app.
      Job configuration

    8. In the Deploy Script field, change the cf push command to cf push "${CF_APP}"-test -n "${CF_APP}"-test. This stage is configured to stop if the job fails.
      This command deploys the app to the test server.
      Deploy job script

      Note: For the new stage, the app name (as shown in the Application name field) has -test appended to it. That name is set by the push "${CF_APP}"-test command. Similarly, the deployed app will be running at a route that looks like {Application name}-test.mybluemix.net (with no curly brackets) because of the -n attribute that sets the host name.

    9. Click SAVE.

    10. Drag the stage that you just created so that it is between the first two stages.
      Drag and drop to reorder the stages

    11. View the updated pipeline.
      Updated pipeline with three stages

    12. Click the Run Stage button in the new stage.
      Run new stage

    13. Review the pipeline after all three stages run.
      Ran new stage

    14. Launch the application to confirm the change to the URL.
      Updated application URL

      For more information about the delivery pipeline, see the Pipeline overview in the IBM Cloud Docs.
      To learn about the practice of creating and using delivery pipelines, see Automate continuous delivery through a delivery pipeline.
      How easy or difficult was it to add a stage to the pipeline and run the updated pipeline?
      Add comments ...

    Start task 4

    Task 4: Delete the toolchain (Optional)

    When you're finished with this tutorial, you can delete the toolchain and all the artifacts that you created.

    By design, deleting the toolchain does not affect either the source code repositories or any applications that the toolchain deployed. You might want those artifacts to have a lifespan beyond that of the toolchain. However, deleting the toolchain does delete any credentials or other information that you entered when you created or edited the toolchain, including the definitions for any pipelines that it included. Before you delete the toolchain, be sure to record any information that you want to keep.

    Use the following instructions to delete the tutorial repositories and any apps that were created, if you no longer need them, and then delete the toolchain.

    Delete the git repos associated with the toolchain

    1. Navigate to the toolchain Overview page for the toolchain that you want to delete.

    2. For each repo you want to delete, click the repo tile on the toolchain's Overview page. Depending on which repo you were using, you might click Git, GitHub, or GitHub Enterprise. The user interface that is provided by the git service is displayed.

      • In GitHub and GitHub Enterprise, click the Settings tab, scroll to the Danger Zone section, and click Delete this repository.
        Delete GitHub repo

        In the "Are you absolutely sure?" window, type the name of the repo and click I understand the consequences, delete this repository.
        Delete GitHub repo confirmation

      • In Git Repos and Issue Tracking, click Settings. On the General page, in the Advanced Settings section, click Expand. Scroll down and click Remove project.
        Delete Git Repos and Issue Tracking repo

        In the "Confirmation required" window, type the repo name and click Confirm.
        Delete GitHub repo confirmation

    Delete the app and other associated resources

    1. Navigate to the IBM Cloud Resource List.

    2. Use the filter controls to find the applications created by the toolchain.
      Resource list

    3. For each app, click the action menu and click Delete.
      Toolchain connections page

    4. In the confirmation window, select the check box to also delete the route.
      App deletion confirmation

    5. Click Delete.

    6. Repeat steps 3 to 5 for each app deployed by the toolchain.

    Delete the toolchain

    1. Return to the toolchain's Overview page. Click the More Actions menu and click Delete.
      Delete toolchain

    2. In the confirmation window, type the name of the toolchain and then click Delete.
      Toolchain deletion confirmation


Comments

Popular posts from this blog

Remote Friendly Companies

GitHub Actions: A Comprehensive Guide to Automation from Scratch

Introduction to Istio, Kiali, Jaeger, Grafana, and Prometheus