Skip to content

Modify (build + package) + deploy to go with new indicator versioning Actions workflow #1755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,41 @@
- TODO: #527 Get this list automatically from python-ci.yml at runtime.
*/
def indicator_list = ["backfill_corrections", "changehc", "claims_hosp", "google_symptoms", "hhs_hosp", "jhu", "nchs_mortality", "quidel", "quidel_covidtest", "safegraph_patterns", "sir_complainsalot", "usafacts", "dsew_community_profile", "doctor_visits"]
def build_package = [:]
def build_package_main = [:]
def build_package_prod = [:]
def deploy_staging = [:]
def deploy_production = [:]

pipeline {
agent any
stages {
stage('Build and Package') {
stage('Build and Package main') {
when {
branch "main";
}
steps {
script {
indicator_list.each { indicator ->
build_package[indicator] = {
sh "jenkins/build-and-package.sh ${indicator}"
build_package_main[indicator] = {
sh "jenkins/build-and-package.sh ${indicator} main"
}
}
parallel build_package
parallel build_package_main
}
}
}
stage('Build and Package prod') {
when {
branch "prod";
}
steps {
script {
indicator_list.each { indicator ->
build_package_prod[indicator] = {
sh "jenkins/build-and-package.sh ${indicator} prod"
}
}
parallel build_package_prod
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ansible/ansible-deploy-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
tasks:
- name: Copy and unarchive the package into the indicators runtime host directory.
unarchive:
src: "{{ jenkins_artifact_dir }}/{{ package }}"
src: "{{ jenkins_artifact_dir }}/{{ package_staging }}"
dest: "{{ indicators_runtime_dir }}"
owner: "{{ runtime_user }}"
group: "{{ runtime_user }}"
Expand Down
2 changes: 1 addition & 1 deletion ansible/ansible-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
tasks:
- name: Copy and unarchive the package into the indicators runtime host directory.
unarchive:
src: "{{ jenkins_artifact_dir }}/{{ package }}"
src: "{{ jenkins_artifact_dir }}/{{ package_production }}"
dest: "{{ indicators_runtime_dir }}"
owner: "{{ runtime_user }}"
group: "{{ runtime_user }}"
Expand Down
3 changes: 2 additions & 1 deletion ansible/vars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ runtime_user: "indicators"
jenkins_user: "jenkins"
jenkins_artifact_dir: "/var/lib/jenkins/artifacts"
indicators_runtime_dir: "/home/{{ runtime_user }}/runtime"
package: "{{ indicator }}.tar.gz" # {{ indicator }} is passed in from the Jenkins shell script wrapper.
package_staging: "main_{{ indicator }}.tar.gz" # {{ indicator }} is passed in from the Jenkins shell script wrapper.
package_production: "prod_{{ indicator }}.tar.gz" # {{ indicator }} is passed in from the Jenkins shell script wrapper.
python_version: "3.8.2"
pyenv_python_path: "/home/{{ runtime_user }}/.pyenv/versions/{{ python_version }}/bin/python"

Expand Down
3 changes: 2 additions & 1 deletion jenkins/build-and-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ source ~/.bash_profile

# Vars
local_indicator=$1
branch=$2

#
# Build
Expand All @@ -30,4 +31,4 @@ pip install ../_delphi_utils_python/. --retries 10 --timeout 20
cd "${WORKSPACE}" || exit

# Create .tar.gz for deployment
tar -czvf "${JENKINS_HOME}/artifacts/${local_indicator}.tar.gz" "${local_indicator}"
tar -czvf "${JENKINS_HOME}/artifacts/${branch}_${local_indicator}.tar.gz" "${local_indicator}"