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

Jenkins integration with Kabanero

duration 30 minutes

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

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

In this guide, you will learn how to use Tekton 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 Tekton tasks and pipelines that are intended to work out of the box with Kabanero Collections 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 Tekton pipelines.

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

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

Intended audience

The purpose of the guide is to show an existing Jenkins user or administrator how to build an image with Tekton 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 Tekton.


You need the following prerequisites to complete the guide:

See each project’s documentation for necessary system requirements.

Build an image with Tekton using an automated webhook

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

  2. While 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 for Kabanero Foundation 0.3.2:

    oc apply -n kabanero -f
  4. Run the following command to get the Tekton 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 Tekton 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-pipeline Pipeline, kabanero-operator 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 Tekton 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 Tekton 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.

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 Appsody is installed, go to your project folder and run the following command to generate an app-deploy.yaml file:

    appsody-deploy –-generate-only

    Other tools, including Jenkins, can use this file for application deployment. Commit and push this file to the root of your project. Jenkins creates the AppsodyApplication resource in the OpenShift cluster and uses Appsody to deploy the application by using the app-deploy.yaml file.

  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

Copied to clipboard
Copy code block

Way to go! What's next?

What could make this guide better?

Raise an issue to share feedback

Create a pull request to contribute to this guide

Need help?

Ask a question on Stack Overflow

Where to next?