Questo contenuto non è disponibile nella lingua selezionata.
Chapter 3. Migrating from Jenkins to OpenShift Pipelines or Tekton
You can migrate your CI/CD workflows from Jenkins to Red Hat OpenShift Pipelines, a cloud-native CI/CD experience based on the Tekton project.
3.1. Comparison of Jenkins and OpenShift Pipelines concepts Copia collegamentoCollegamento copiato negli appunti!
You can review and compare the following equivalent terms used in Jenkins and OpenShift Pipelines.
3.1.1. Jenkins terminology Copia collegamentoCollegamento copiato negli appunti!
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.
3.1.2. OpenShift Pipelines terminology Copia collegamentoCollegamento copiato negli appunti!
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.
NoteYou 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.
NoteIn 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.
3.1.3. Mapping of concepts Copia collegamentoCollegamento copiato negli appunti!
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:
Jenkins | OpenShift Pipelines |
---|---|
Pipeline | Pipeline and PipelineRun |
Stage | Task |
Step | A step in a task |
3.2. Migrating a sample pipeline from Jenkins to OpenShift Pipelines Copia collegamentoCollegamento copiato negli appunti!
You can use the following equivalent examples to help migrate your build, test, and deploy pipelines from Jenkins to OpenShift Pipelines.
3.2.1. Jenkins pipeline Copia collegamentoCollegamento copiato negli appunti!
Consider a Jenkins pipeline written in Groovy for building, testing, and deploying:
3.2.2. OpenShift Pipelines pipeline Copia collegamentoCollegamento copiato negli appunti!
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
Example test
task YAML definition file
Example deploy
task YAML definition file
You can combine the three tasks sequentially to form a pipeline in OpenShift Pipelines:
Example: OpenShift Pipelines pipeline for building, testing, and deployment
3.3. Migrating from Jenkins plugins to Tekton Hub tasks Copia collegamentoCollegamento copiato negli appunti!
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
3.4. Extending OpenShift Pipelines capabilities using custom tasks and scripts Copia collegamentoCollegamento copiato negli appunti!
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
Example: Run a custom shell script by providing its path
Example: Run a custom Python script by writing it in the YAML file
3.5. Comparison of Jenkins and OpenShift Pipelines execution models Copia collegamentoCollegamento copiato negli appunti!
Jenkins and OpenShift Pipelines offer similar functions but are different in architecture and execution.
Jenkins | OpenShift Pipelines |
---|---|
Jenkins has a controller node. Jenkins runs pipelines and steps centrally, or orchestrates jobs running in other nodes. | OpenShift Pipelines is serverless and distributed, and there is no central dependency for execution. |
Containers are launched by the Jenkins controller node through the pipeline. | OpenShift Pipelines adopts a 'container-first' approach, where every step runs as a container in a pod (equivalent to nodes in Jenkins). |
Extensibility is achieved by using plugins. | Extensibility is achieved by using tasks in Tekton Hub or by creating custom tasks and scripts. |
3.6. Examples of common use cases Copia collegamentoCollegamento copiato negli appunti!
Both Jenkins and OpenShift Pipelines offer capabilities for common CI/CD use cases, such as:
- Compiling, building, and deploying images using Apache Maven
- Extending the core capabilities by using plugins
- Reusing shareable libraries and custom scripts
3.6.1. Running a Maven pipeline in Jenkins and OpenShift Pipelines Copia collegamentoCollegamento copiato negli appunti!
You can use Maven in both Jenkins and OpenShift Pipelines workflows for compiling, building, and deploying images. To map your existing Jenkins workflow to OpenShift Pipelines, consider the following examples:
Example: Compile and build an image and deploy it to OpenShift using Maven in Jenkins
Example: Compile and build an image and deploy it to OpenShift using Maven in OpenShift Pipelines.
3.6.2. Extending the core capabilities of Jenkins and OpenShift Pipelines by using plugins Copia collegamentoCollegamento copiato negli appunti!
Jenkins has the advantage of a large ecosystem of numerous plugins developed over the years by its extensive user base. You can search and browse the plugins in the Jenkins Plugin Index.
OpenShift Pipelines also has many tasks developed and contributed by the community and enterprise users. A publicly available catalog of reusable OpenShift Pipelines tasks are available in the Tekton Hub.
In addition, OpenShift Pipelines incorporates many of the plugins of the Jenkins ecosystem within its core capabilities. For example, authorization is a critical function in both Jenkins and OpenShift Pipelines. While Jenkins ensures authorization using the Role-based Authorization Strategy plugin, OpenShift Pipelines uses OpenShift’s built-in Role-based Access Control system.
3.6.3. Sharing reusable code in Jenkins and OpenShift Pipelines Copia collegamentoCollegamento copiato negli appunti!
Jenkins shared libraries provide reusable code for parts of Jenkins pipelines. The libraries are shared between Jenkinsfiles to create highly modular pipelines without code repetition.
Although there is no direct equivalent of Jenkins shared libraries in OpenShift Pipelines, you can achieve similar workflows by using tasks from the Tekton Hub in combination with custom tasks and scripts.