Skip to content

Commit

Permalink
Adding support for a build project
Browse files Browse the repository at this point in the history
  • Loading branch information
etsauer committed Feb 28, 2018
1 parent 974015f commit 6c4f8a6
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 19 deletions.
13 changes: 6 additions & 7 deletions basic-spring-boot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ oc login
$ ansible-playbook -i ./applier/inventory/ /path/to/casl-ansible/playbooks/openshift-cluster-seed.yml
```

At this point you should have 3 projects deployed (`basic-spring-boot-dev`, `basic-spring-boot-stage`, and `basic-spring-boot-prod`) with our [Spring Rest](https://github.com/redhat-cop/spring-rest.git) demo application deployed to all 3.
At this point you should have 3 projects deployed (`basic-spring-boot-build`, `basic-spring-boot-dev`, `basic-spring-boot-stage`, and `basic-spring-boot-prod`) with our [Spring Rest](https://github.com/redhat-cop/spring-rest.git) demo application deployed to all 3.

## Architecture

Expand Down Expand Up @@ -51,12 +51,9 @@ The idea behind the split between the templates is that I can deploy the build t
This project includes a sample `Jenkinsfile` pipeline script that could be included with a Java project in order to implement a basic CI/CD pipeline for that project, under the following assumptions:

* The project is built with Maven
* The `Jenkinsfile` script is placed in the same directory as the `pom.xml` file in the git source.
* The OpenShift projects that represent the Application's lifecycle stages are of the naming format: `<app-name>-dev`, `<app-name>-stage`, `<app-name>-prod`.

For convenience, this pipeline script is already included in the following git repository, based on our [Spring Boot Demo App](https://github.com/redhat-cop/spring-rest) app.

https://github.com/redhat-cop/spring-rest
This pipeline defaults to use our [Spring Boot Demo App](https://github.com/redhat-cop/spring-rest).

## Bill of Materials

Expand All @@ -70,6 +67,7 @@ https://github.com/redhat-cop/spring-rest

For the purposes of this demo, we are going to create three stages for our application to be promoted through.

- `basic-spring-boot-build`
- `basic-spring-boot-dev`
- `basic-spring-boot-stage`
- `basic-spring-boot-prod`
Expand All @@ -78,6 +76,7 @@ In the spirit of _Infrastructure as Code_ we have a YAML file that defines the `

```
$ oc create -f applier/projects/projects.yml
projectrequest "basic-spring-boot-build" created
projectrequest "basic-spring-boot-dev" created
projectrequest "basic-spring-boot-stage" created
projectrequest "basic-spring-boot-prod" created
Expand All @@ -88,7 +87,7 @@ projectrequest "basic-spring-boot-prod" created
For this step, the OpenShift default template set provides exactly what we need to get jenkins up and running.

```
$ oc process openshift//jenkins-ephemeral | oc apply -f- -n basic-spring-boot-dev
$ oc process openshift//jenkins-ephemeral | oc apply -f- -n basic-spring-boot-build
route "jenkins" created
deploymentconfig "jenkins" created
serviceaccount "jenkins" created
Expand Down Expand Up @@ -150,5 +149,5 @@ At this point you should be able to go to the Web Console and follow the pipelin
Cleaning up this example is as simple as deleting the projects we created at the beginning.

```
oc delete project basic-spring-boot-dev basic-spring-boot-prod basic-spring-boot-stage
oc delete project basic-spring-boot-build basic-spring-boot-dev basic-spring-boot-prod basic-spring-boot-stage
```
4 changes: 3 additions & 1 deletion basic-spring-boot/applier/params/build-dev
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
APPLICATION_NAME=spring-rest
NAMESPACE=basic-spring-boot-dev
NAMESPACE=basic-spring-boot-build
SOURCE_REPOSITORY_URL=https://github.com/etsauer/container-pipelines.git
SOURCE_REPOSITORY_REF=applier-enable
2 changes: 1 addition & 1 deletion basic-spring-boot/applier/params/deployment-dev
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
APPLICATION_NAME=spring-rest
NAMESPACE=basic-spring-boot-dev
SA_NAMESPACE=basic-spring-boot-dev
SA_NAMESPACE=basic-spring-boot-build
READINESS_RESPONSE=status.:.UP
READINESS_PATH=/health
2 changes: 1 addition & 1 deletion basic-spring-boot/applier/params/deployment-prod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
APPLICATION_NAME=spring-rest
NAMESPACE=basic-spring-boot-prod
SA_NAMESPACE=basic-spring-boot-dev
SA_NAMESPACE=basic-spring-boot-build
READINESS_RESPONSE=status.:.UP
READINESS_PATH=/health
2 changes: 1 addition & 1 deletion basic-spring-boot/applier/params/deployment-stage
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
APPLICATION_NAME=spring-rest
NAMESPACE=basic-spring-boot-stage
SA_NAME=jenkins
SA_NAMESPACE=basic-spring-boot-dev
SA_NAMESPACE=basic-spring-boot-build
READINESS_RESPONSE=status.:.UP
READINESS_PATH=/health
12 changes: 9 additions & 3 deletions basic-spring-boot/applier/projects/projects.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
apiVersion: v1
kind: List
items:
- kind: ProjectRequest
apiVersion: v1
metadata:
name: basic-spring-boot-build
creationTimestam: null
displayName: Spring Rest App - Build
- kind: ProjectRequest
apiVersion: v1
metadata:
name: basic-spring-boot-dev
creationTimestam: null
displayName: Dev - Spring Rest App
displayName: Spring Rest App - Dev
- kind: ProjectRequest
apiVersion: v1
metadata:
name: basic-spring-boot-stage
creationTimestam: null
displayName: Staging - Spring Rest App
displayName: Spring Rest App - Stage
- kind: ProjectRequest
apiVersion: v1
metadata:
name: basic-spring-boot-prod
creationTimestam: null
displayName: Prod - Spring Rest App
displayName: Spring Rest App - Prod
21 changes: 16 additions & 5 deletions basic-spring-boot/applier/templates/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ metadata:
version: 1.2.0
name: generic-java-jenkins-pipeline
objects:
- apiVersion: v1
kind: ImageStream
metadata:
labels:
application: ${APPLICATION_NAME}
name: ${APPLICATION_NAME}
namespace: ${NAMESPACE}
- kind: "BuildConfig"
apiVersion: "v1"
metadata:
Expand All @@ -33,9 +40,9 @@ objects:
type: "JenkinsPipeline"
jenkinsPipelineStrategy:
jenkinsfilePath: ${PIPELINE_SCRIPT}
env:
- name: "BUILD_CONTEXT_DIR"
value: "demo"
env:
- name: "APPLICATION_SOURCE_REPO"
value: "${APPLICATION_SOURCE_REPO}"
- apiVersion: v1
kind: BuildConfig
metadata:
Expand Down Expand Up @@ -69,13 +76,17 @@ parameters:
- description: Git source URI for application
name: SOURCE_REPOSITORY_URL
required: true
value: https://github.com/redhat-cop/spring-rest.git
value: https://github.com/redhat-cop/container-pipelines.git
- description: Git branch/tag reference
name: SOURCE_REPOSITORY_REF
value: "master"
- description: Path within Git project to build; empty for root project directory.
name: CONTEXT_DIR
value:
value: basic-spring-boot
- description: Source code repo for demo app
name: APPLICATION_SOURCE_REPO
required: true
value: https://github.com/redhat-cop/spring-rest.git
- description: Path within Git project pointing to the pipeline run script
name: PIPELINE_SCRIPT
value: Jenkinsfile
Expand Down

0 comments on commit 6c4f8a6

Please sign in to comment.