Skip to content

Commit

Permalink
Add advanced pipeline examples
Browse files Browse the repository at this point in the history
  • Loading branch information
csrwng committed Dec 8, 2016
1 parent a3cb5df commit 22121a4
Show file tree
Hide file tree
Showing 8 changed files with 2,366 additions and 996 deletions.
93 changes: 87 additions & 6 deletions examples/jenkins/pipeline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
This set of files will allow you to deploy a Jenkins server that is capable of executing Jenkins pipelines and
utilize pods run on OpenShift as Jenkins slaves.

## Basic Pipeline

To walk through the example:

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

If you used cluster up:

$ oc new-app jenkins-pipeline-example

Otherwise:
$ oc new-app -f https://raw.githubusercontent.com/openshift/origin/master/examples/jenkins/pipeline/samplepipeline.json

$ oc new-app -f https://raw.githubusercontent.com/openshift/origin/master/examples/jenkins/pipeline/samplepipeline.yaml

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.

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

$ oc annotate sa/jenkins serviceaccounts.openshift.io/oauth-redirecturi.1=http://<jenkins_service_ip:jenkins_service_port>/securityRealm/finishLogin --overwrite

Only include the port in the uri if it is not port 80.

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

$ oc start-build sample-pipeline

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.
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.

If you monitor the pods in your default project, you will also see the slave pod get created and deleted.

## Maven Slave Example

The `maven-pipeline.yaml` template contains a pipeline that uses a maven node to build and package a WAR.
It then builds an image with the WAR using a Docker build.

To run this example:

1. Ensure that you have a running OpenShift environment as described in the basic example
2. Create a new project for your pipeline on the OpenShift web console:
1. Login
2. Click on *New Project*
3. Enter a project name
4. Click *Create*
3. In the *Add to Project* page, click on *Import YAML/JSON*
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.
5. Paste the YAML text in the text box of the *Import YAML/JSON* tab.
6. Click on *Create*
7. Leave *Process the template* checked and click on *Continue*
8. Modify the URL and Reference of the code repository if you have created your own fork.
9. Click on *Create*
10. Navigate to *Builds* -> *Pipelines*
11. Click on *Start Pipeline* next to *openshift-jee-sample*

When the pipeline completes, the openshift-jee-sample application should be deployed and running.

## Orchestration Pipeline Example

The `mapsapp-pipeline.yaml` template contains a pipeline that instantiates other pipelines and runs them.
It shows how more than one pipeline can be launched in parallel and how a single Jenkins pipeline
can work with multiple source code repositories.

To run this example:

1. Ensure that you have a running OpenShift environment as described in the basic example
2. Create a new project for your pipeline on the OpenShift web console:
1. Login
2. Click on *New Project*
3. Enter a project name
4. Click *Create*
3. In the *Add to Project* page, click on *Import YAML/JSON*
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.
5. Paste the YAML text in the text box of the *Import YAML/JSON* tab.
6. Click on *Create*
7. Leave *Process the template* checked and click on *Continue*
8. Modify the URLs and References of the sample repositories if you have created your own forks.
9. Click on *Create*
10. Navigate to *Builds* -> *Pipelines*
11. Click on *Start Pipeline* next to *mapsapp-pipeline*

On the first pipeline run, there will be a delay as Jenkins is instantiated for the project. The pipeline will instantiate
other pipelines and those will in turn instantiate OpenShift objects. Once the pipeline has completed, a maps frontend
should be running with 2 backends: nationalparks and mlbparks.


## Blue Green Deployment Example

The `bluegreen-pipeline.yaml` template contains a pipeline that demonstrates alternating blue/green deployments with a manual
approval step.

To run this example:

1. Create a fork of https://github.com/openshift/nodejs-ex.git
2. Create a new project for your pipeline on the OpenShift web console:
1. Login
2. Click on *New Project*
3. Enter a project name
4. Click *Create*
3. In the *Add to Project* page, click on *Import YAML/JSON*
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.
5. Paste the YAML text in the text box of the *Import YAML/JSON* tab.
6. Click on *Create*
7. Leave *Process the template* checked and click on *Continue*
8. Modify the *Git Repository URL* to contain the URL of your fork
9. Click on *Create*
10. Navigate to *Builds* -> *Pipelines*
11. Click on *Start Pipeline* next to *bluegreen-pipeline*
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.
13. Push a change to your fork of the nodejs-ex repository
14. Start the pipeline again. Go back to step 11 and repeat.
Loading

0 comments on commit 22121a4

Please sign in to comment.