Skip to content

Commit

Permalink
Merge pull request #212 from hcorson-dosch-usgs/fix_jenkins_setup
Browse files Browse the repository at this point in the history
update jenkins file to match vue3-template repo setup
  • Loading branch information
hcorson-dosch-usgs committed Jul 18, 2024
2 parents 0009803 + 8cd40e9 commit dbe6f61
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 114 deletions.
39 changes: 19 additions & 20 deletions jenkins/Jenkinsfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}"]]
])
}
}
Expand All @@ -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}"
Expand All @@ -51,44 +53,41 @@ 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
"""
}
}
}

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}"
}
Expand Down
94 changes: 0 additions & 94 deletions jenkins/JenkinsfileUnified.build

This file was deleted.

0 comments on commit dbe6f61

Please sign in to comment.