Skip to main content
AI
  • Get started with AI

    • Red Hat AI

      Accelerate the development and deployment of enterprise AI solutions.

    • AI learning hub

      Explore learning materials and tools, organized by task.

    • AI interactive demos

      Click through scenarios with Red Hat AI, including training LLMs and more.

    • AI/ML learning paths

      Expand your Red Hat OpenShift AI knowledge using these learning resources.

    • AI quickstarts

      Focused AI use cases designed for fast deployment on Red Hat AI platforms.

    • No-cost AI training

      Foundational Red Hat AI training.

  • Featured resources

    • Red Hat OpenShift AI
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

Red Hat AI Factory with NVIDIA

Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.

Learn
  • Self-guided

    • Documentation

      Find answers, get step-by-step guidance, and learn how to use Red Hat products.

    • Learning paths

      Explore curated walkthroughs for common development tasks.

    • Guided learning

      Receive custom learning paths powered by our AI assistant.

    • See all learning
  • Hands-on

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

    • Interactive labs

      Learn by doing in these hands-on, browser-based experiences.

    • Interactive demos

      Click through product features in these guided tours.

  • Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics
  • Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
Build
  • Get started

    • Red Hat build of Podman Desktop

      A downloadable, local development hub to experiment with our products and builds.

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

  • Download products

    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products
  • Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset
  • References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
Community
  • Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions
  • Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github
  • Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

Join the Red Hat Developer program

Download Red Hat products and project builds, access support documentation, learning content, and more.

ConsoleDocsSupport Search
New For you

Recommended

We'll recommend resources you may like as you browse. Try these suggestions for now.

  • Product downloads
  • Cheat sheets
  • Red Hat Developer learning portal
  • Developer blog
  • E-books
  • Developer Sandbox
Log in

Get more with a Red Hat Developer account

  • Product downloads
  • Console access
  • Event registration
  • Training & trials
Explore more account benefitsLog in or register

A subscription may be required for some services.

Contact us

How to use continuous integration with Jenkins on OpenShift

February 28, 2023
Nagesh Rathod
Related topics:
AutomationCI/CDContainers
Related products:
Red Hat Ansible Automation PlatformRed Hat OpenShiftRed Hat Quay

    In this article series, we will set up a continuous integration (CI) pipeline to compile and package a JavaScript game application into a Docker image using Jenkins on Red Hat OpenShift. Once we build the image, it will be pushed to the external Red Hat Quay container registry, Quay.io. When the developer pushes the changes into the Git repository, all these actions trigger.

    This is a series of complete CI/CD pipelines on OpenShift using the Jenkins and Red Hat Ansible Automation Platform. We will cover the following topics:

    • Part 1: Continuous integration with Jenkins on OpenShift
    • Part 2: Continuous deployment using Ansible Automation Platform on OpenShift
    • Part 3: How a manual intervention pipeline restricts deployment

    This article is based on the assumption that you have basic knowledge of Jenkins, OpenShift, and Ansible Automation Platform. You will also need administrator privileges for your OpenShift cluster.

    The CI pipeline architecture

    The developer commits and pushes the changes after initiating the action, as shown in the architecture diagram (Figure 1). Jenkins will detect the changes with the help of polling or webhooks. We build the image in the OpenShift cluster and push it to the Quay.io container registry using buildconfig.

    A diagram of continuous integration architecture.
    Figure 1: A continuous integration architecture diagram.

    Install Jenkins on OpenShift

    Now we need Jenkins Dashboard, which will run the CI pipeline. The easiest way is to deploy a pod of Jenkins on OpenShift from the developer's catalog, as shown in Figure 2.

    A screenshot of the Developer Catalog from where you can install Jenkins.
    Figure 2: Install Jenkins from the Developer Catalog.

    Follow these six steps to install Jenkins on OpenShift:

    1. From OpenShift Web Console, switch to the Developer perspective and navigate to the Topology view. Click on +Add > From Developer Catalog > All services
    2. Search for Jenkins.
    3. Select the persistence Jenkins and install it (For this article, I am keeping the settings as default, but you can modify the settings as per your requirement).
    4. After installation, one Jenkins pod should appear in the project.
    5. To access the dashboard of Jenkins, click on the route icon.
    6. For Jenkins dashboard access, you can use the OpenShift console credential, as shown in Figure 3.
    The Jenkins login screen with OpenShift credentials.
    Figure 3: The Jenkins login screen with OpenShift credentials.

    Set up Jenkins CI pipeline

    The continuous integration stage consists of building and pushing the image into the container registry.

    1. Make sure to have one git repository in place, including the Dockerfile and application dependencies like the requirements.txt file.
    2. Create a Jenkinsfile with the following contents and add this jenkinsfile to the git repository.
    pipeline {
        agent any
    
        stages {
            stage('Hello') {
                steps {
                    echo 'Hello World'
                }
            }
            stage("Checkout") {
                steps {
                    checkout scm
                }
            }
            stage("Docker Build") {
                steps {
                  sh '''
                      #oc start-build --from-build=<build_name>
                      oc start-build -F red-api --from-dir=./api/
                  '''
                }
            }
        }
    }

     

    3. Next, create a BuildConfig file using the following content that will build the source code to executable and push.

    apiVersion: build.OpenShift.io/v1
    kind: BuildConfig
    metadata:
      labels:
        app.kubernetes.io/name: red-api # your application name
      name: red-api # your application name
    spec:
      output:
        to:
          kind: DockerImage
          name: ***************** # add yourimage
      source:
        # Expect a local directory to be streamed to OpenShift as a build source
        type: Binary
        binary: {}
      strategy:
        type: Docker
        dockerStrategy:
          # Find the image build instructions in./Dockerfile
          dockerfilePath: Dockerfile

    Ex: name: quay.io/<username>/cd:latest

    4. Next, create the secrets which will help our build config to push our recently built image in the container registry.

    5. To create a secret, type the following command into your terminal and make sure to use the username and password of your environment. For this exercise, we are using a Quay.io container registry.

    $ oc create secret docker-registry my-secret --docker-server=quay.io --docker-username=xxxx  --docker-password=xxx
    
    
    $ oc secrets link builder my-secret --for=mount

    6. Next, we will create a pipeline from the Jenkins dashboard (Figure 4).

    A screenshot of the Jenkins dashboard.
    Figure 4: The Jenkins dashboard​​​​​ after installation.

    7. Select Pipeline from New Item and give a name to that pipeline.

    8. Select the Build Triggers when the changes are pushed in the GitHub repository.

    9. In the pipeline, select Pipeline Script from SCM.

    10. Fill in the details according to the snapshot shown in Figure 5 for the config we're using for this article.

    Ansible Automation Platform integrate with jenkins pipeline​​​​​​.
    Figure 5: Integrate Ansible Automation Platform with Jenkins pipeline​​​​​​.

    11. Once the pipeline is ready, execute it by clicking the Build Now button. You can see a glimpse of the pipeline in Figure 6.

    A screenshot showing the completed CI stage and the CI pipeline running in the Jenkins dashboard.
    Figure 6: The CI pipeline running in the Jenkins dashboard.

    What’s Next?

    The next article is based on the continuous deployment using the Ansible Automation platform on the OpenShift cluster. You will learn how to install the Ansible Automation platform using the operator’s hub on OpenShift and also the integration of Jenkins and Ansible Automation platform. Check out a demo of this project in DevNation2022.

    Last updated: September 27, 2024

    Related Posts

    • Integrate Continuous Integration with OpenShift Enterprise

    • 5 principles for deploying your API from a CI/CD pipeline

    • How to build cloud-native CI/CD pipelines with Tekton on Kubernetes

    • An introduction to cloud-native CI/CD with Red Hat OpenShift Pipelines

    • Introducing Ansible Molecule with Ansible Automation Platform

    • Get started with Jenkins CI/CD in Red Hat OpenShift 4

    Recent Posts

    • A day in the life of an NVIDIA H100 on Red Hat OpenShift 5

    • Migrate BuildConfigs to builds for Red Hat OpenShift with one plug-in install

    • Run Red Hat Enterprise Linux CoreOS on NVIDIA BlueField DPUs

    • Agent harness engineering: Separating model capabilities from enforcement

    • What's new for developers in Red Hat Enterprise Linux 10.3 and 9.9

    What’s up next?

    Get a preview of the Red Hat Certified Engineer (RHCE) Ansible Automation Study Guide (O’Reilly), which covers key Ansible concepts for your system administration needs.

    Get the e-book
    Red Hat Developers logo

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    Red Hat Developer

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility
    Ask AI