diff --git a/basic-spring-boot/.applier/group_vars/seed-hosts.yml b/basic-spring-boot/.applier/group_vars/seed-hosts.yml index 7d4895ef..4cb40a3d 100644 --- a/basic-spring-boot/.applier/group_vars/seed-hosts.yml +++ b/basic-spring-boot/.applier/group_vars/seed-hosts.yml @@ -27,6 +27,9 @@ openshift_cluster_content: params_from_vars: APPLICATION_NAME: "{{ sb_application_name }}" NAMESPACE: "{{ sb_build_namespace }}" + NAMESPACE_DEV: "{{ sb_dev_namespace }}" + NAMESPACE_STAGE: "{{ sb_stage_namespace }}" + NAMESPACE_PROD: "{{ sb_prod_namespace }}" SOURCE_REPOSITORY_URL: "{{ sb_source_repository_url }}" SOURCE_REPOSITORY_REF: "{{ sb_source_repository_ref }}" APPLICATION_SOURCE_REPO: "{{ sb_application_repository_url }}" diff --git a/basic-spring-boot/.openshift/templates/build.yml b/basic-spring-boot/.openshift/templates/build.yml index 73f84fdf..a030d97c 100644 --- a/basic-spring-boot/.openshift/templates/build.yml +++ b/basic-spring-boot/.openshift/templates/build.yml @@ -49,10 +49,20 @@ objects: jenkinsPipelineStrategy: jenkinsfilePath: ${PIPELINE_SCRIPT} env: + - name: "APP_NAME" + value: "${APPLICATION_NAME}" - name: "APPLICATION_SOURCE_REPO" value: "${APPLICATION_SOURCE_REPO}" - name: "APPLICATION_SOURCE_REF" value: "${APPLICATION_SOURCE_REF}" + - name: "NAMESPACE_BUILD" + value: "${NAMESPACE}" + - name: "NAMESPACE_DEV" + value: "${NAMESPACE_DEV}" + - name: "NAMESPACE_STAGE" + value: "${NAMESPACE_STAGE}" + - name: "NAMESPACE_PROD" + value: "${NAMESPACE_PROD}" - apiVersion: build.openshift.io/v1 kind: BuildConfig metadata: @@ -84,7 +94,7 @@ parameters: name: APPLICATION_NAME required: true value: basic-spring -- description: The namespace to deploy into +- description: The namespace that will contain the build resources defined in this template name: NAMESPACE required: true - description: Git source URI for application @@ -107,6 +117,15 @@ parameters: - description: Path within Git project pointing to the pipeline run script name: PIPELINE_SCRIPT value: Jenkinsfile +- description: The namespace containing dev resources + name: NAMESPACE_DEV + required: true +- description: The namespace containing stage resources + name: NAMESPACE_STAGE + required: true +- description: The namespace containing prod resources + name: NAMESPACE_PROD + required: true - description: GitHub trigger secret from: '[a-zA-Z0-9]{8}' generate: expression diff --git a/basic-spring-boot/Jenkinsfile b/basic-spring-boot/Jenkinsfile index 74e3e666..082d8a6f 100644 --- a/basic-spring-boot/Jenkinsfile +++ b/basic-spring-boot/Jenkinsfile @@ -9,12 +9,11 @@ retriever: modernSCM( openshift.withCluster() { env.NAMESPACE = openshift.project() env.POM_FILE = env.BUILD_CONTEXT_DIR ? "${env.BUILD_CONTEXT_DIR}/pom.xml" : "pom.xml" - env.APP_NAME = "${JOB_NAME}".replaceAll(/-build.*/, '') - echo "Starting Pipeline for ${APP_NAME}..." - env.BUILD = "${env.NAMESPACE}" - env.DEV = "${APP_NAME}-dev" - env.STAGE = "${APP_NAME}-stage" - env.PROD = "${APP_NAME}-prod" + echo "Starting Pipeline for ${env.APP_NAME}..." + env.BUILD = "${env.NAMESPACE_BUILD}" + env.DEV = "${env.NAMESPACE_DEV}" + env.STAGE = "${env.NAMESPACE_STAGE}" + env.PROD = "${env.NAMESPACE_PROD}" } pipeline {