Check out what's in the latest release of Kabanero Learn More

Jenkins integration

duration 30 minutes

The product delivers a modern DevOps toolchain with pre-built pipelines. Kubernetes-style resources are provided for declaring CI/CD-style pipelines. While it is advantageous to run both CI and CD style pipelines to leverage the power of Kubernetes, some might want to reuse Jenkins assets or skills.

With the product, you can customize the deployment section of the pipeline to use Jenkins.

In this guide, you will learn how to build an image and how to use Jenkins to deploy an application that uses that image. The kabanero-pipelines repository contains a collection of tasks and pipelines that are intended to work out of the box with application stacks to illustrate a CI/CD workflow. The pipelines and tasks can be run manually or by using a webhook. This guide shows you how to use an automated webhook to create and run pipelines.

The following diagram depicts the relationship and flow between the pipeline and Jenkins:

This diagram depicts the relationship and flow between the pipeline and Jenkins.

Intended audience

The purpose of the guide is to show an existing Jenkins user or administrator how to build an image with the pipeline and how to deploy an image with Jenkins. Users should have experience with Jenkins and be familiar with the fundamental concepts of microservices, Docker, Kubernetes, and pipelines.


You need the following prerequisites to complete the guide:

See each project’s documentation for necessary system requirements.

Build an image with an automated webhook

  1. Log in as cluster-admin in the master node of your Kubernetes cluster. The following steps assume that you are logged in as cluster-admin, and the commands are run on the master node of your Kubernetes cluster.

  2. While you are logged in as a cluster-admin, run the installation script from the kabanero-operator release:

    curl -s -L | bash
  3. Create an instance of Kabanero CR by running the command that you see as output near the end of the previous installation script. For example, run the following command:

    oc apply -n kabanero -f
  4. Run the following command to get the pipelines dashboard URL:

    kubectl get routes -n tekton-pipelines

    The output looks like the following example:

    NAME               HOST/PORT                                                         PATH   SERVICES           PORT
    tekton-dashboard          tekton-dashboard   <all>
  5. From the pipelines dashboard, go to Webhooks and click on the + next to Add Webhook.

  6. From Webhook Settings, give your webhook a name, repository URL, and access token. The webhook name can be anything. This example uses a Java MicroProfile pipeline, so your codebase should be Java MicroProfile-based. If you don’t have a Java MicroProfile codebase, you can fork this repo. To learn how to create a personal access token for GitHub, see GitHub’s documentation.

  7. From Target Pipeline Settings, select Kabanero namespace, java-microprofile-build-push-jk-pl Pipeline, kabanero-pipeline Service Account, and your OpenShift Registry URL in image-registry.openshift-image-registry.svc:5000/<projectname> form.

  8. Go to the PipelineRuns tab. If you didn’t already create PipelineRuns, the list is empty.

  9. In GitHub, go to SettingsWebhooks. You can see your new webhook, which was created by the the pipelines dashboard.

  10. Now make any code change in your repository and push the change. Wait a few moments and you can see a PipelineRun start under the PipelineRuns tab on your pipelines dashboard.

  11. After the PipelineRun finishes successfully, log in to your OpenShift Registry and find the new image. The image resides under a repository with the same name as your GitHub repository. Note: Kabanero Pipelines will use Project Name as the image name and latest git commit id as the tag; by design.

    • Note: If you use an external image registry, you’ll have to configure the secrets in the pipelines dashboard and you’ll find the image under that external image registry.

Deploy an image with Jenkins

  1. Create a Jenkinsfile: Use the Jenkinsfile template from the reference section of this guide, and change the Docker Hub source to your own image repository. Push this Jenkinsfile to your GitHub repository in the root location.

  2. Create a deploy file: On your local environment where your development application is installed, go to your project folder and run the following command to generate an app-deploy.yaml file:

    appsody build

    Other tools, including Jenkins, can use this file for development application deployment. Commit and push this file to the root of your project. Jenkins creates the AppsodyApplication resource in the OpenShift cluster and uses your application to deploy the application by using the app-deploy.yaml file. Update app-deploy.yaml file with your desired image name to match the IMAGENAME envVar in the Jenkinsfile you will create below.

      name: java-microprofile
  3. Create a Jenkins project and pipeline: Create a Jenkins (Ephemeral) instance by running the following command:

    oc new-app jenkins-ephemeral -n kabanero

    Next, in the OpenShift UI go to NetworkingRoutes, select the Kabanero project, and find the Jenkins URL in the Location column. From Jenkins, create a project and specify GitHub as the source. Provide your GitHub account and repository details and choose multi-branch pipeline creation. Jenkins automatically detects the Jenkinsfile in your GitHub repository and starts the deployment process.

  4. Verify deployment: Go to NetworkingRoutes and select the Kabanero project to see the successful deployment. You can also see the URL of the running application by going to NetworkingRoutes.


  • The following file is a sample Jenkinsfile that you can use to set up your initial Jenkinsfile for the guide. The user might need to adjust the following values: envVars: [ envVar(key: 'TAG', value: 'latest'), envVar(key: 'IMAGENAME', value: 'java-microprofile'), envVar(key: 'PROJECT', value: 'kabanero')])

podTemplate(label: 'label', cloud: 'openshift', serviceAccount: 'kabanero-pipeline', containers: [
    containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl', ttyEnabled: true, command: 'cat',
                      envVars: [ envVar(key: 'TAG', value: 'latest'),
                                envVar(key: 'IMAGENAME', value: 'java-microprofile'),
                               envVar(key: 'PROJECT', value: 'kabanero')])
    node('label') {
        stage('Deploy') {
            container('kubectl') {
                checkout scm
                sh 'sed -i -e \'s#applicationImage: .*$#applicationImage: image-registry.openshift-image-registry.svc:5000/\'$PROJECT\'/\'$IMAGENAME\':\'$TAG\'#g\' app-deploy.yaml'
                sh 'cat app-deploy.yaml'
                sh 'find . -name app-deploy.yaml -type f|xargs kubectl apply -f'
  • This guide was tested on the following product versions: OpenShift 4.2 Platform, Kabanero Foundation 0.3.1, Tekton 0.7, Jenkins ver. 2.176.3

Way to go! What's next?

What could make this guide better?

Raise an issue to share feedback

Edit or create new guides to help contribute

Need help?

Ask a question on Stack Overflow

Where to next?