Skip to content

Latest commit

 

History

History
 
 

lab205

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Lab 205

Jenkins CICD

Create Jenkins pipeline build

  • Duration: 15 mins
  • Audience: Developers, Architects, Devops

Overview

This section covers how to create an openshift pipeline build to trigger a jenkins slave and deploy our API in Openshift.

Environment

URLs:

Check with your instruction the GUID number of your current workshop environment. Replace the actual number on all the URLs where you find GUID.

Example in case of GUID = cluster-lhm8v.lhm8v.sandbox430:

https://console-openshift-console.apps.GUID.opentlc.com

becomes =>

https://console-openshift-console.apps.cluster-lhm8v.lhm8v.sandbox430.opentlc.com

Credentials:

Your username is your asigned user number. For example, if you are assigned user number 1, your username is:

user1

The password to login is always the same:

openshift

Lab Instructions

Step 0: Login your OC Cli

One of the prerequisites of this course is having an OC Cli already installed. if you don't have please go to Install Openshift CLI.

  1. Once you have the Openshift Cli, you need to login, Open a new temrinal and type the following:

  2. Open a browser window and navigate to:

    oc login https://api.GUID.opentlc.com:6443 -p $PASSWORD -u $USER

    Remember to replace the GUID with your environment value and your user number.

  3. Once you have been loged in, you need to create a new build Jenkins pipeline Build.

    oc new-build http://gogs.apps.GUID.opentlc.com/userX/todo-app.git#main --name=todo-app-pipeline -n user1
  4. The first time it will fail, this is because we haven't set the variables needed for the pipeline to run.

  5. If you want to see how it fails, please go to Builds section.

    pipeline

  6. Choose the todo-app-pipeline build config, and then clic Builds tab

    pipeline

    pipeline

  7. Select the failed build todo-app-pipeline-1 and see the error.

    pipeline

  8. To set the variables type the following command:

     oc set env bc/todo-app-pipeline GIT_REPO="http://gogs.apps.GUID.opentlc.com/userX/todo-app.git" \
     GIT_BRANCH="main" PARAMS_OPENAPI_SPEC="src/openapi/openapi.yaml" \
     APP_NAME="todo_api" \
     PRIVATE_URL="http://todo-app-userX.apps.GUID.opentlc.com" \
     INSTANCE="3scale-onprem" OCP_PROJECT="userX" \
     SECRET_NAME="3scale-toolbox" TEST_ENDPOINT="/items" -n userX
  9. Start the new build manually by running the follwing command:

        oc start-build todo-app-pipeline -n userX
  10. Once the pipeline has finished succesfully, you will see the pipeline as this: pipeline-successful

  11. You can access again 3scale admin portal to check if the new API has been created.

        https://userX-admin.apps.GUID.opentlc.com

    new-api

    Note: If it fails try to guess why it is, Hint: Could be the account assigned to the application plan doesn't exists? Try to update your Jenkinsfile if it fails with the right number

  12. Check if it's promoted until production. You can check it by clicking Integrations -> Configuration under Todo List (v1.0.0)

    production

Steps Beyond

So, you want more? Have you tried to define the API using Oauth instead of api-key? Have you checked the Jenkinsfile, you could add the app deployment and the api together.

Summary

In this lab you have learned how to create builds of type pipeline and deploy APIs trough the API.

Notes and Further Reading