diff --git a/basic-spring-boot/README.md b/basic-spring-boot/README.md index ab9b272f..1ef0c396 100644 --- a/basic-spring-boot/README.md +++ b/basic-spring-boot/README.md @@ -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 @@ -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: `-dev`, `-stage`, `-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 @@ -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` @@ -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 @@ -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 @@ -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 ``` diff --git a/basic-spring-boot/applier/params/build-dev b/basic-spring-boot/applier/params/build-dev index 7c801449..6ffde5f3 100644 --- a/basic-spring-boot/applier/params/build-dev +++ b/basic-spring-boot/applier/params/build-dev @@ -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 diff --git a/basic-spring-boot/applier/params/deployment-dev b/basic-spring-boot/applier/params/deployment-dev index b6d9208a..441eebe9 100644 --- a/basic-spring-boot/applier/params/deployment-dev +++ b/basic-spring-boot/applier/params/deployment-dev @@ -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 diff --git a/basic-spring-boot/applier/params/deployment-prod b/basic-spring-boot/applier/params/deployment-prod index 58e4a1eb..e09e4dda 100644 --- a/basic-spring-boot/applier/params/deployment-prod +++ b/basic-spring-boot/applier/params/deployment-prod @@ -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 diff --git a/basic-spring-boot/applier/params/deployment-stage b/basic-spring-boot/applier/params/deployment-stage index b26e06b1..d0c280ad 100644 --- a/basic-spring-boot/applier/params/deployment-stage +++ b/basic-spring-boot/applier/params/deployment-stage @@ -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 diff --git a/basic-spring-boot/applier/projects/projects.yml b/basic-spring-boot/applier/projects/projects.yml index e0d600b9..e22e0c60 100644 --- a/basic-spring-boot/applier/projects/projects.yml +++ b/basic-spring-boot/applier/projects/projects.yml @@ -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 diff --git a/basic-spring-boot/applier/templates/build.yml b/basic-spring-boot/applier/templates/build.yml index b72504b9..90c54a4a 100644 --- a/basic-spring-boot/applier/templates/build.yml +++ b/basic-spring-boot/applier/templates/build.yml @@ -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: @@ -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: @@ -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