diff --git a/jenkins/Jenkinsfile.build b/jenkins/Jenkinsfile.build index 444b16b..105a28a 100644 --- a/jenkins/Jenkinsfile.build +++ b/jenkins/Jenkinsfile.build @@ -4,13 +4,15 @@ pipeline { label 'team:makerspace-small' } } - + triggers { pollSCM('*/5 * * * *') } parameters { - choice(choices: ['test', 'qa', 'beta', 'prod'], description: 's3 bucket that the build will target', name: 'BUILD_DEST') - choice(choices: ['test', 'qa', 'beta', 'prod'], description: 'The mode selected will tell Vue which environment variables to use. Various feature flags will be disabled/enabled depending on mode. More importantly, the source of the tiles will change, with the development build loading tiles from the test S3 bucket and the production build loading tiles from the prod S3 bucket.', name: 'VUE_BUILD_MODE') + choice(choices: ['test', 'beta', 'prod'], description: 's3 bucket that the build will target', name: 'BUILD_DEST') + choice(choices: ['test', 'beta', 'prod'], description: 'The mode selected will tell Vue which environment variables to use. Various feature flags will be disabled/enabled depending on mode. More importantly, the source of the tiles will change, with the development build loading tiles from the test S3 bucket and the production build loading tiles from the prod S3 bucket.', name: 'VUE_BUILD_MODE') + choice(choices: ['gages-through-the-ages'], description: 'project name, url extension, and GitLab repository name, matching VITE_APP_TITLE set in .env', name: 'VITE_APP_TITLE') gitParameter(name: 'BRANCH_TAG', type: 'PT_BRANCH_TAG', - defaultValue: 'master') + selectedValue: 'DEFAULT', + defaultValue: 'origin/main') } stages { @@ -27,7 +29,7 @@ pipeline { extensions: [], gitTool: 'Default', submoduleCfg: [], - userRemoteConfigs: [[url: 'https://github.com/usgs-makerspace/gages-through-the-ages']] + userRemoteConfigs: [[url: "https://github.com/DOI-USGS/${params.VITE_APP_TITLE}.git", credentialsId: "vizlab_jenkins_${params.VITE_APP_TITLE}"]] ]) } } @@ -36,9 +38,9 @@ pipeline { steps { sh """ - docker build . --tag="gages-through-the-ages-docker" --build-arg BUILDTARGET=${params.BUILD_DEST} --build-arg VUE_BUILD_MODE=${params.VUE_BUILD_MODE} - docker run gages-through-the-ages-docker - pathtemplate=":tmp/gages-through-the-ages/dist" + docker build . --tag="${params.VITE_APP_TITLE}-docker" --build-arg BUILD_DEST=${params.BUILD_DEST} --build-arg VUE_BUILD_MODE=${params.VUE_BUILD_MODE} --build-arg VITE_APP_TITLE=${params.VITE_APP_TITLE} + docker run ${params.VITE_APP_TITLE}-docker + pathtemplate=":tmp/${params.VITE_APP_TITLE}/dist" dockerinstanceid=\$( docker ps -l -q ) docker cp "\${dockerinstanceid}\${pathtemplate}" "$WORKSPACE" docker rm "\${dockerinstanceid}" @@ -51,21 +53,18 @@ pipeline { steps { script { if ("${params.BUILD_DEST}" == "prod") { - targetDomain = "s3://gages-through-the-ages-prod-website" - } - else if ("${params.BUILD_DEST}" == "qa") { - targetDomain = "s3://gages-through-the-ages-qa-website" + targetDomain = "s3://water-visualizations-prod-website/visualizations/${params.VITE_APP_TITLE}" } else if ("${params.BUILD_DEST}" == "beta") { - targetDomain = "s3://gages-through-the-ages-beta-website" + targetDomain = "s3://water-visualizations-beta-website/visualizations/${params.VITE_APP_TITLE}" } else { - targetDomain = "s3://gages-through-the-ages-test-website" + targetDomain = "s3://water-visualizations-test-website/visualizations/${params.VITE_APP_TITLE}" } } sh """ - aws s3 rm "${targetDomain}" - aws s3 cp "$WORKSPACE/dist" "${targetDomain}"/gages-through-the-ages --recursive + aws s3 rm "${targetDomain}" --recursive + aws s3 cp "$WORKSPACE/dist" "${targetDomain}" --recursive """ } } @@ -73,22 +72,22 @@ pipeline { post { success { - mail to: 'abriggs@contractor.usgs.gov, mwernimont@contractor.usgs.gov', + mail to: 'cnell@usgs.gov', subject: "Success: ${currentBuild.fullDisplayName}", body: "Pipeline finished successfully ${env.BUILD_URL}" } unstable { - mail to: 'abriggs@contractor.usgs.gov, mwernimont@contractor.usgs.gov', + mail to: 'cnell@usgs.gov', subject: "Unstable: ${currentBuild.fullDisplayName}", body: "Pipeline is unstable ${env.BUILD_URL}" } failure { - mail to: 'abriggs@contractor.usgs.gov, mwernimont@contractor.usgs.gov', + mail to: 'cnell@usgs.gov', subject: "Failure: ${currentBuild.fullDisplayName}", body: "Pipeline failed ${env.BUILD_URL}" } changed { - mail to: 'abriggs@contractor.usgs.gov, mwernimont@contractor.usgs.gov', + mail to: 'cnell@usgs.gov', subject: "Changes: ${currentBuild.fullDisplayName}", body: "Pipeline detected changes ${env.BUILD_URL}" } diff --git a/jenkins/JenkinsfileUnified.build b/jenkins/JenkinsfileUnified.build deleted file mode 100644 index 8bc5f70..0000000 --- a/jenkins/JenkinsfileUnified.build +++ /dev/null @@ -1,94 +0,0 @@ -pipeline { - agent { - node { - label 'team:makerspace-small' - } - } - triggers { pollSCM('*/5 * * * *') } - parameters { - choice(choices: ['test', 'beta', 'prod'], description: 's3 bucket that the build will target', name: 'BUILD_DEST') - choice(choices: ['test', 'beta', 'prod'], description: 'The mode selected will tell Vue which environment variables to use. Various feature flags will be disabled/enabled depending on mode. More importantly, the source of the tiles will change, with the development build loading tiles from the test S3 bucket and the production build loading tiles from the prod S3 bucket.', name: 'VUE_BUILD_MODE') - gitParameter(name: 'BRANCH_TAG', - type: 'PT_BRANCH_TAG', - selectedValue: 'DEFAULT', - defaultValue: 'origin/master') - } - - stages { - stage('clean workspace'){ - steps{ - cleanWs() - } - } - stage('checkout'){ - steps{ - checkout([$class: 'GitSCM', - branches: [[name: "${params.BRANCH_TAG}"]], - doGenerateSubmoduleConfigurations: false, - extensions: [], - gitTool: 'Default', - submoduleCfg: [], - userRemoteConfigs: [[url: 'https://github.com/usgs-makerspace/gages-through-the-ages.git']] - ]) - } - } - - stage('build') { - steps { - - sh """ - docker build . --tag="gages-through-the-ages-docker" --build-arg BUILDTARGET=${params.BUILD_DEST} --build-arg VUE_BUILD_MODE=${params.VUE_BUILD_MODE} - docker run gages-through-the-ages-docker - pathtemplate=":tmp/gages-through-the-ages/dist" - dockerinstanceid=\$( docker ps -l -q ) - docker cp "\${dockerinstanceid}\${pathtemplate}" "$WORKSPACE" - docker rm "\${dockerinstanceid}" - """ - - } - } - - stage('send to S3') { - steps { - script { - if ("${params.BUILD_DEST}" == "prod") { - targetDomain = "s3://water-visualizations-prod-website/visualizations/gages-through-the-ages" - } - else if ("${params.BUILD_DEST}" == "beta") { - targetDomain = "s3://water-visualizations-beta-website/visualizations/gages-through-the-ages" - } - else { - targetDomain = "s3://water-visualizations-test-website/visualizations/gages-through-the-ages" - } - } - sh """ - aws s3 rm "${targetDomain}" --recursive - aws s3 cp "$WORKSPACE/dist" "${targetDomain}" --recursive - """ - } - } - } - - post { - success { - mail to: 'cnell@usgs.gov, ebechtel@contractor.usgs.gov, lplatt@usgs.gov', - subject: "Success: ${currentBuild.fullDisplayName}", - body: "Pipeline finished successfully ${env.BUILD_URL}" - } - unstable { - mail to: 'cnell@usgs.gov, ebechtel@contractor.usgs.gov, lplatt@usgs.gov', - subject: "Unstable: ${currentBuild.fullDisplayName}", - body: "Pipeline is unstable ${env.BUILD_URL}" - } - failure { - mail to: 'cnell@usgs.gov, ebechtel@contractor.usgs.gov, lplatt@usgs.gov', - subject: "Failure: ${currentBuild.fullDisplayName}", - body: "Pipeline failed ${env.BUILD_URL}" - } - changed { - mail to: 'cnell@usgs.gov, ebechtel@contractor.usgs.gov, lplatt@usgs.gov', - subject: "Changes: ${currentBuild.fullDisplayName}", - body: "Pipeline detected changes ${env.BUILD_URL}" - } - } -}