×

Comparison of Jenkins and OpenShift Pipelines concepts

You can review and compare the following equivalent terms used in Jenkins and OpenShift Pipelines.

Jenkins terminology

Jenkins offers declarative and scripted pipelines that are extensible using shared libraries and plugins. Some basic terms in Jenkins are as follows:

  • Pipeline: Automates the entire process of building, testing, and deploying applications by using Groovy syntax.

  • Node: A machine capable of either orchestrating or executing a scripted pipeline.

  • Stage: A conceptually distinct subset of tasks performed in a pipeline. Plugins or user interfaces often use this block to display the status or progress of tasks.

  • Step: A single task that specifies the exact action to be taken, either by using a command or a script.

OpenShift Pipelines terminology

OpenShift Pipelines uses YAML syntax for declarative pipelines and consists of tasks. Some basic terms in OpenShift Pipelines are as follows:

  • Pipeline: A set of tasks in a series, in parallel, or both.

  • Task: A sequence of steps as commands, binaries, or scripts.

  • PipelineRun: Execution of a pipeline with one or more tasks.

  • TaskRun: Execution of a task with one or more steps.

    You can initiate a PipelineRun or a TaskRun with a set of inputs such as parameters and workspaces, and the execution results in a set of outputs and artifacts.

  • Workspace: In OpenShift Pipelines, workspaces are conceptual blocks that serve the following purposes:

    • Storage of inputs, outputs, and build artifacts.

    • Common space to share data among tasks.

    • Mount points for credentials held in secrets, configurations held in config maps, and common tools shared by an organization.

    In Jenkins, there is no direct equivalent of OpenShift Pipelines workspaces. You can think of the control node as a workspace, as it stores the cloned code repository, build history, and artifacts. When a job is assigned to a different node, the cloned code and the generated artifacts are stored in that node, but the control node maintains the build history.

Mapping of concepts

The building blocks of Jenkins and OpenShift Pipelines are not equivalent, and a specific comparison does not provide a technically accurate mapping. The following terms and concepts in Jenkins and OpenShift Pipelines correlate in general:

Table 1. Jenkins and OpenShift Pipelines - basic comparison
Jenkins OpenShift Pipelines

Pipeline

Pipeline and PipelineRun

Stage

Task

Step

A step in a task

Migrating a sample pipeline from Jenkins to OpenShift Pipelines

You can use the following equivalent examples to help migrate your build, test, and deploy pipelines from Jenkins to OpenShift Pipelines.

Jenkins pipeline

Consider a Jenkins pipeline written in Groovy for building, testing, and deploying:

pipeline {
   agent any
   stages {
       stage('Build') {
           steps {
               sh 'make'
           }
       }
       stage('Test'){
           steps {
               sh 'make check'
               junit 'reports/**/*.xml'
           }
       }
       stage('Deploy') {
           steps {
               sh 'make publish'
           }
       }
   }
}

OpenShift Pipelines pipeline

To create a pipeline in OpenShift Pipelines that is equivalent to the preceding Jenkins pipeline, you create the following three tasks:

Example build task YAML definition file
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: myproject-build
spec:
  workspaces:
  - name: source
  steps:
  - image: my-ci-image
    command: ["make"]
    workingDir: $(workspaces.source.path)
Example test task YAML definition file
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: myproject-test
spec:
  workspaces:
  - name: source
  steps:
  - image: my-ci-image
    command: ["make check"]
    workingDir: $(workspaces.source.path)
  - image: junit-report-image
    script: |
      #!/usr/bin/env bash
      junit-report reports/**/*.xml
    workingDir: $(workspaces.source.path)
Example deploy task YAML definition file
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: myprojectd-deploy
spec:
  workspaces:
  - name: source
  steps:
  - image: my-deploy-image
    command: ["make deploy"]
    workingDir: $(workspaces.source.path)

You can combine the three tasks sequentially to form a pipeline in OpenShift Pipelines:

Example: OpenShift Pipelines pipeline for building, testing, and deployment
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: myproject-pipeline
spec:
  workspaces:
  - name: shared-dir
  tasks:
  - name: build
    taskRef:
      name: myproject-build
    workspaces:
    - name: source
      workspace: shared-dir
  - name: test
    taskRef:
      name: myproject-test
    workspaces:
    - name: source
      workspace: shared-dir
  - name: deploy
    taskRef:
      name: myproject-deploy
    workspaces:
    - name: source
      workspace: shared-dir

Migrating from Jenkins plugins to Tekton Hub tasks

You can extend the capability of Jenkins by using plugins. To achieve similar extensibility in OpenShift Pipelines, use any of the tasks available from Tekton Hub.

For example, consider the git-clone task in Tekton Hub, which corresponds to the git plugin for Jenkins.

Example: git-clone task from Tekton Hub
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
 name: demo-pipeline
spec:
 params:
   - name: repo_url
   - name: revision
 workspaces:
   - name: source
 tasks:
   - name: fetch-from-git
     taskRef:
       name: git-clone
     params:
       - name: url
         value: $(params.repo_url)
       - name: revision
         value: $(params.revision)
     workspaces:
     - name: output
       workspace: source

Extending OpenShift Pipelines capabilities using custom tasks and scripts

In OpenShift Pipelines, if you do not find the right task in Tekton Hub, or need greater control over tasks, you can create custom tasks and scripts to extend the capabilities of OpenShift Pipelines.

Example: A custom task for running the maven test command
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: maven-test
spec:
  workspaces:
  - name: source
  steps:
  - image: my-maven-image
    command: ["mvn test"]
    workingDir: $(workspaces.source.path)
Example: Run a custom shell script by providing its path
...
steps:
  image: ubuntu
  script: |
      #!/usr/bin/env bash
      /workspace/my-script.sh
...
Example: Run a custom Python script by writing it in the YAML file
...
steps:
  image: python
  script: |
      #!/usr/bin/env python3
      print(“hello from python!”)
...

Comparison of Jenkins and OpenShift Pipelines execution models

Jenkins and OpenShift Pipelines offer similar functions but are different in architecture and execution.

Table 2. Comparison of execution models in Jenkins and OpenShift Pipelines
Jenkins OpenShift Pipelines

Jenkins has a controller node. Jenkins runs