Skip to content

Commit e404bf2

Browse files
author
Souvik Sarkar
committed
Jenkins to Tekton Migration Guide
Jenkins to Tekton migration guide content Resolved Pavol's comments Refactoring into modules Fixed file-not-found error fixed errors pointed out by Preeti Fixed wrong file name Fixed typos Peer review comments from Jake Incorporated Sri's comments
1 parent 5b68e24 commit e404bf2

7 files changed

+320
-0
lines changed

_topic_map.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,12 @@ Topics:
14091409
- Name: Setting up additional trusted certificate authorities for builds
14101410
File: setting-up-trusted-ca
14111411
Distros: openshift-enterprise,openshift-origin,openshift-dedicated
1412+
- Name: Migrating from Jenkins to Tekton
1413+
Dir: jenkins-tekton
1414+
Distros: openshift-enterprise
1415+
Topics:
1416+
- Name: Migrating from Jenkins to Tekton
1417+
File: migrating-from-jenkins-to-tekton
14121418
- Name: Pipelines
14131419
Dir: pipelines
14141420
Distros: openshift-enterprise
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//Jenkins-Tekton-Migration
2+
include::modules/common-attributes.adoc[]
3+
include::modules/pipelines-document-attributes.adoc[]
4+
[id="migrating-from-jenkins-to-tekton_{context}"]
5+
= Migrating from Jenkins to Tekton
6+
:context: migrating-from-jenkins-to-tekton
7+
//include::modules/common-attributes.adoc[]
8+
9+
toc::[]
10+
11+
12+
Jenkins and Tekton are extensively used to automate the process of building, testing, and deploying applications and projects. However, Tekton is a cloud-native CI/CD solution that works seamlessly with Kubernetes and {product-title}. This document helps you migrate your Jenkins CI/CD workflows to Tekton.
13+
14+
include::modules/jt-comparison-of-jenkins-and-tekton-concepts.adoc[leveloffset=+1]
15+
16+
include::modules/jt-migrating-a-sample-pipeline-from-jenkins-to-tekton.adoc[leveloffset=+1]
17+
18+
include::modules/jt-migrating-from-jenkins-plugins-to-tekton-hub-tasks.adoc[leveloffset=+1]
19+
20+
include::modules/jt-extending-tekton-capabilities-using-custom-tasks-and-scripts.adoc[leveloffset=+1]
21+
22+
include::modules/jt-comparison-of-jenkins-tekton-execution-models.adoc[leveloffset=+1]
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Module included in the following assembly:
2+
//
3+
// jenkins-tekton/migrating-from-jenkins-to-tekton.adoc
4+
5+
[id="jt-comparison-of-jenkins-and-tekton-concepts_{context}"]
6+
= Comparison of Jenkins and Tekton concepts
7+
8+
toc::[]
9+
10+
11+
This section summarizes the basic terms used in Jenkins and Tekton, and compares the equivalent terms.
12+
13+
== Jenkins terminology
14+
Jenkins offers declarative and scripted pipelines that are extensible using shared libraries and plugins. Some basic terms in Jenkins are as follows:
15+
16+
* *Pipeline*: Automates the entire process of building, testing, and deploying applications, using the link:https://groovy-lang.org/[Groovy] syntax.
17+
* *Node*: A machine capable of either orchestrating or executing a scripted pipeline.
18+
* *Stage*: A conceptually distinct subset of tasks performed in a pipeline. Plugins or user interfaces often use this block to display status or progress of tasks.
19+
* **Step**: A single task that specifies the exact action to be taken, either by using a command or a script.
20+
21+
== Tekton terminology
22+
Tekton uses the link:https://yaml.org/[YAML] syntax for declarative pipelines and consists of tasks. Some basic terms in Tekton are as follows:
23+
24+
* **Pipeline**: A set of tasks in a series, in parallel, or both.
25+
* **Task**: A sequence of steps as commands, binaries, or scripts.
26+
* **PipelineRun**: Execution of a pipeline with one or more tasks.
27+
* **TaskRun**: Execution of a task with one or more steps.
28+
+
29+
[NOTE]
30+
====
31+
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.
32+
====
33+
* **Workspace**: In Tekton, workspaces are conceptual blocks that serve the following purposes:
34+
35+
** Storage of inputs, outputs, and build artifacts.
36+
37+
** Common space to share data among tasks.
38+
39+
** Mount points for credentials held in secrets, configurations held in config maps, and common tools shared by an organization.
40+
41+
+
42+
[NOTE]
43+
====
44+
In Jenkins, there is no direct equivalent of Tekton workspaces. You can think of the control node as a workspace, as it stores the cloned code repository, build history, and artifacts. In situations where a job is assigned to a different node, the cloned code and the generated artifacts are stored in that node, but the build history is maintained by the control node.
45+
====
46+
47+
== Mapping of concepts
48+
The building blocks of Jenkins and Tekton are not equivalent, and a comparison does not provide a technically accurate mapping. The following terms and concepts in Jenkins and Tekton correlate in general:
49+
50+
.Jenkins and Tekton - basic comparison
51+
[cols="1,1",options="header"]
52+
|===
53+
|Jenkins|Tekton
54+
|Pipeline|Pipeline and PipelineRun
55+
|Stage|Task
56+
|Step|A step in a task
57+
|===
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Module included in the following assembly:
2+
//
3+
// jenkins-tekton/migrating-from-jenkins-to-tekton.adoc
4+
5+
[id="jt-comparison-of-jenkins-tekton-execution-models_{context}"]
6+
= Comparison of Jenkins and Tekton execution models
7+
8+
Jenkins and Tekton offer similar functions but are different in architecture and execution. This section outlines a brief comparison of the two execution models.
9+
10+
.Comparison of execution models in Jenkins and Tekton
11+
[cols="1,1",options="header"]
12+
|===
13+
|Jenkins|Tekton
14+
|Jenkins has a control node. Jenkins executes pipelines and steps centrally, or orchestrates jobs running in other nodes.|Tekton is serverless and distributed, and there is no central dependency for execution.
15+
|The containers are launched by the control node through the pipeline.|Tekton adopts a 'container-first' approach, where every step is executed as a container running in a pod (equivalent to nodes in Jenkins).
16+
|Extensibility is achieved using plugins.|Extensibility is achieved using tasks in Tekton Hub, or by creating custom tasks and scripts.
17+
|===
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Module included in the following assembly:
2+
//
3+
// jenkins-tekton/migrating-from-jenkins-to-tekton.adoc
4+
5+
[id="jt-extending-tekton-capabilities-using-custom-tasks-and-scripts_{context}"]
6+
= Extending Tekton capabilities using custom tasks and scripts
7+
8+
toc::[]
9+
10+
11+
In Tekton, 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 Tekton's capabilities.
12+
13+
.Example: Custom task for running the `maven test` command
14+
[source,yaml,subs="attributes+"]
15+
----
16+
apiVersion: tekton.dev/v1beta1
17+
kind: Task
18+
metadata:
19+
name: maven-test
20+
spec:
21+
workspaces:
22+
- name: source
23+
steps:
24+
- image: my-maven-image
25+
command: ["mvn test"]
26+
workingDir: $(workspaces.source.path)
27+
----
28+
29+
.Example: Execute a custom shell script by providing its path
30+
[source,yaml,subs="attributes+"]
31+
----
32+
...
33+
steps:
34+
image: ubuntu
35+
script: |
36+
#!/usr/bin/env bash
37+
/workspace/my-script.sh
38+
...
39+
----
40+
41+
.Example: Execute a custom Python script by writing it in the YAML file
42+
[source,yaml,subs="attributes+"]
43+
----
44+
...
45+
steps:
46+
image: python
47+
script: |
48+
#!/usr/bin/env python3
49+
print(“hello from python!”)
50+
...
51+
----
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// Module included in the following assembly:
2+
//
3+
// jenkins-tekton/migrating-from-jenkins-to-tekton.adoc
4+
5+
[id="jt-migrating-a-sample-pipeline-from-jenkins-to-tekton_{context}"]
6+
= Migrating a sample pipeline from Jenkins to Tekton
7+
8+
toc::[]
9+
10+
11+
This section provides equivalent examples of pipelines in Jenkins and Tekton and helps you to migrate your build, test, and deploy pipelines from Jenkins to Tekton.
12+
13+
== Jenkins pipeline
14+
Consider a Jenkins pipeline written in Groovy for building, testing, and deploying:
15+
[source,groovy,subs="attributes+"]
16+
----
17+
pipeline {
18+
agent any
19+
stages {
20+
stage('Build') {
21+
steps {
22+
sh 'make'
23+
}
24+
}
25+
stage('Test'){
26+
steps {
27+
sh 'make check'
28+
junit 'reports/**/*.xml'
29+
}
30+
}
31+
stage('Deploy') {
32+
steps {
33+
sh 'make publish'
34+
}
35+
}
36+
}
37+
}
38+
----
39+
40+
== Tekton pipeline
41+
In Tekton, the equivalent example of the Jenkins pipeline comprises of three tasks, each of which can be written declaratively using the YAML syntax:
42+
43+
.Example `build` task
44+
[source,yaml,subs="attributes+"]
45+
----
46+
apiVersion: tekton.dev/v1beta1
47+
kind: Task
48+
metadata:
49+
name: myproject-build
50+
spec:
51+
workspaces:
52+
- name: source
53+
steps:
54+
- image: my-ci-image
55+
command: ["make"]
56+
workingDir: $(workspaces.source.path)
57+
----
58+
59+
.Example `test` task:
60+
[source,yaml,subs="attributes+"]
61+
----
62+
apiVersion: tekton.dev/v1beta1
63+
kind: Task
64+
metadata:
65+
name: myproject-test
66+
spec:
67+
workspaces:
68+
- name: source
69+
steps:
70+
- image: my-ci-image
71+
command: ["make check"]
72+
workingDir: $(workspaces.source.path)
73+
- image: junit-report-image
74+
script: |
75+
#!/usr/bin/env bash
76+
junit-report reports/**/*.xml
77+
workingDir: $(workspaces.source.path)
78+
----
79+
80+
.Example `deploy` task:
81+
[source,yaml,subs="attributes+"]
82+
----
83+
apiVersion: tekton.dev/v1beta1
84+
kind: Task
85+
metadata:
86+
name: myprojectd-deploy
87+
spec:
88+
workspaces:
89+
- name: source
90+
steps:
91+
- image: my-deploy-image
92+
command: ["make deploy"]
93+
workingDir: $(workspaces.source.path)
94+
----
95+
96+
You can combine the three tasks sequentially to form a Tekton pipeline:
97+
98+
.Example: Tekton pipeline for building, testing, and deployment
99+
[source,yaml,subs="attributes+"]
100+
----
101+
apiVersion: tekton.dev/v1beta1
102+
kind: Pipeline
103+
metadata:
104+
name: myproject-pipeline
105+
spec:
106+
workspaces:
107+
- name: shared-dir
108+
tasks:
109+
- name: build
110+
taskRef:
111+
name: myproject-build
112+
workspaces:
113+
- name: source
114+
workspace: shared-dir
115+
- name: test
116+
taskRef:
117+
name: myproject-test
118+
workspaces:
119+
- name: source
120+
workspace: shared-dir
121+
- name: deploy
122+
taskRef:
123+
name: myproject-deploy
124+
workspaces:
125+
- name: source
126+
workspace: shared-dir
127+
----
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Module included in the following assembly:
2+
//
3+
// jenkins-tekton/migrating-from-jenkins-to-tekton.adoc
4+
5+
[id="jt-migrating-from-jenkins-plugins-to-tekton-hub-tasks_{context}"]
6+
= Migrating from Jenkins plugins to Tekton Hub tasks
7+
8+
toc::[]
9+
10+
11+
You can exend the capability of Jenkins by using link:https://plugins.jenkinsci.org[plugins]. To achieve similar extensibility in Tekton, use any of the available tasks from link:https://hub.tekton.dev[Tekton Hub].
12+
13+
As an example, consider the link:https://hub.tekton.dev/tekton/task/git-clone[git-clone] task available in the Tekton Hub, that corresponds to the link:https://plugins.jenkins.io/git/[git plugin] for Jenkins.
14+
15+
.Example: `git-clone` task from Tekton Hub
16+
[source,yaml,subs="attributes+"]
17+
----
18+
apiVersion: tekton.dev/v1beta1
19+
kind: Pipeline
20+
metadata:
21+
name: demo-pipeline
22+
spec:
23+
params:
24+
- name: repo_url
25+
- name: revision
26+
workspaces:
27+
- name: source
28+
tasks:
29+
- name: fetch-from-git
30+
taskRef:
31+
name: git-clone
32+
params:
33+
- name: url
34+
value: $(params.repo_url)
35+
- name: revision
36+
value: $(params.revision)
37+
workspaces:
38+
- name: output
39+
workspace: source
40+
----

0 commit comments

Comments
 (0)