Skip to content

Commit 76e0703

Browse files
committed
Add advanced pipeline examples
1 parent a3cb5df commit 76e0703

File tree

8 files changed

+2114
-1004
lines changed

8 files changed

+2114
-1004
lines changed

examples/jenkins/pipeline/README.md

Lines changed: 87 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
This set of files will allow you to deploy a Jenkins server that is capable of executing Jenkins pipelines and
44
utilize pods run on OpenShift as Jenkins slaves.
55

6+
## Basic Pipeline
7+
68
To walk through the example:
79

810
0. If using `oc cluster up`, be sure to grab the [latest oc command](https://github.com/openshift/origin/releases/latest)
@@ -32,12 +34,12 @@ jenkins template represented by jenkinstemplate.json by running these commands a
3234
4. Run this command to instantiate the template which will create a pipeline buildconfig and some other resources in your project:
3335

3436
If you used cluster up:
35-
37+
3638
$ oc new-app jenkins-pipeline-example
3739

3840
Otherwise:
39-
40-
$ oc new-app -f https://raw.githubusercontent.com/openshift/origin/master/examples/jenkins/pipeline/samplepipeline.json
41+
42+
$ oc new-app -f https://raw.githubusercontent.com/openshift/origin/master/examples/jenkins/pipeline/samplepipeline.yaml
4143

4244
At this point if you run `oc get pods` you should see a jenkins pod, or at least a jenkins-deploy pod. (along with other items in your project) This pod was created as a result of the new pipeline buildconfig being defined by the sample-pipeline template.
4345

@@ -56,7 +58,7 @@ jenkins template represented by jenkinstemplate.json by running these commands a
5658
If you take this approach, run the following command before attempting to log into Jenkins:
5759

5860
$ oc annotate sa/jenkins serviceaccounts.openshift.io/oauth-redirecturi.1=http://<jenkins_service_ip:jenkins_service_port>/securityRealm/finishLogin --overwrite
59-
61+
6062
Only include the port in the uri if it is not port 80.
6163

6264
Login with the user name used to create the "pipelineproject" and any non-empty password.
@@ -65,7 +67,86 @@ jenkins template represented by jenkinstemplate.json by running these commands a
6567

6668
$ oc start-build sample-pipeline
6769

68-
Jenkins will: create an instance of the sample-pipeline job, launch a slave, trigger a build in openshift, trigger a
69-
deployment in openshift, and tear the slave down.
70+
Jenkins will: create an instance of the sample-pipeline job, launch a slave, trigger a build in openshift, trigger a deployment in openshift, and tear the slave down.
7071

7172
If you monitor the pods in your default project, you will also see the slave pod get created and deleted.
73+
74+
## Maven Slave Example
75+
76+
The `maven-pipeline.yaml` template contains a pipeline that uses a maven node to build and package a WAR.
77+
It then builds an image with the WAR using a Docker build.
78+
79+
To run this example:
80+
81+
1. Ensure that you have a running OpenShift environment as described in the basic example
82+
2. Create a new project for your pipeline on the OpenShift web console:
83+
1. Login
84+
2. Click on *New Project*
85+
3. Enter a project name
86+
4. Click *Create*
87+
3. In the *Add to Project* page, click on *Import YAML/JSON*
88+
4. In a separate browser tab, navigate to [maven-pipeline.yaml](https://raw.githubusercontent.com/openshift/origin/master/examples/jenkins/pipeline/maven-pipeline.yaml) and copy its content.
89+
5. Paste the YAML text in the text box of the *Import YAML/JSON* tab.
90+
6. Click on *Create*
91+
7. Leave *Process the template* checked and click on *Continue*
92+
8. Modify the URL and Reference of the code repository if you have created your own fork.
93+
9. Click on *Create*
94+
10. Navigate to *Builds* -> *Pipelines*
95+
11. Click on *Start Pipeline* next to *openshift-jee-sample*
96+
97+
When the pipeline completes, the openshift-jee-sample application should be deployed and running.
98+
99+
## Orchestration Pipeline Example
100+
101+
The `mapsapp-pipeline.yaml` template contains a pipeline that instantiates other pipelines and runs them.
102+
It shows how more than one pipeline can be launched in parallel and how a single Jenkins pipeline
103+
can work with multiple source code repositories.
104+
105+
To run this example:
106+
107+
1. Ensure that you have a running OpenShift environment as described in the basic example
108+
2. Create a new project for your pipeline on the OpenShift web console:
109+
1. Login
110+
2. Click on *New Project*
111+
3. Enter a project name
112+
4. Click *Create*
113+
3. In the *Add to Project* page, click on *Import YAML/JSON*
114+
4. In a separate browser tab, navigate to [mapsapp-pipeline.yaml](https://raw.githubusercontent.com/openshift/origin/master/examples/jenkins/pipeline/mapsapp-pipeline.yaml) and copy its content.
115+
5. Paste the YAML text in the text box of the *Import YAML/JSON* tab.
116+
6. Click on *Create*
117+
7. Leave *Process the template* checked and click on *Continue*
118+
8. Modify the URLs and References of the sample repositories if you have created your own forks.
119+
9. Click on *Create*
120+
10. Navigate to *Builds* -> *Pipelines*
121+
11. Click on *Start Pipeline* next to *mapsapp-pipeline*
122+
123+
On the first pipeline run, there will be a delay as Jenkins is instantiated for the project. The pipeline will instantiate
124+
other pipelines and those will in turn instantiate OpenShift objects. Once the pipeline has completed, a maps frontend
125+
should be running with 2 backends: nationalparks and mlbparks.
126+
127+
128+
## Blue Green Deployment Example
129+
130+
The `bluegreen-pipeline.yaml` template contains a pipeline that demonstrates alternating blue/green deployments with a manual
131+
approval step.
132+
133+
To run this example:
134+
135+
1. Create a fork of https://github.com/openshift/nodejs-ex.git
136+
2. Create a new project for your pipeline on the OpenShift web console:
137+
1. Login
138+
2. Click on *New Project*
139+
3. Enter a project name
140+
4. Click *Create*
141+
3. In the *Add to Project* page, click on *Import YAML/JSON*
142+
4. In a separate browser tab, navigate to [bluegreen-pipeline.yaml](https://raw.githubusercontent.com/openshift/origin/master/examples/jenkins/pipeline/bluegreen-pipeline.yaml) and copy its content.
143+
5. Paste the YAML text in the text box of the *Import YAML/JSON* tab.
144+
6. Click on *Create*
145+
7. Leave *Process the template* checked and click on *Continue*
146+
8. Modify the *Git Repository URL* to contain the URL of your fork
147+
9. Click on *Create*
148+
10. Navigate to *Builds* -> *Pipelines*
149+
11. Click on *Start Pipeline* next to *bluegreen-pipeline*
150+
12. Once the code has been deployed, the pipeline will pause for your approval. Click on the pause icon to approve the deployment of the changes.
151+
13. Push a change to your fork of the nodejs-ex repository
152+
14. Start the pipeline again. Go back to step 11 and repeat.

0 commit comments

Comments
 (0)