Skip to content
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

Add versioning of builds to Jenkinsfile #332

Merged
merged 134 commits into from
Sep 23, 2020
Merged
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
fc04fde
Remove superfluous pip install commands
justaddcoffee Sep 11, 2020
13581b0
Add build versioning to Jenkinsfile, also add code to make index.html…
justaddcoffee Sep 12, 2020
a1b0386
Update Jenkinsfile to do builds, and to make index.html files
justaddcoffee Sep 14, 2020
84af955
Add pip install networkx to Jenkinsfile - seems to be required by kgx…
justaddcoffee Sep 14, 2020
2236b84
Add pandas install before KGX install
justaddcoffee Sep 14, 2020
f37a16d
Added install of KGX requirements
justaddcoffee Sep 14, 2020
177d7a2
Update merge step by leveraging KGX
deepakunni3 Sep 12, 2020
670900c
Set checkpoint to false in merge.yaml
deepakunni3 Sep 12, 2020
f74203a
Fix tests
deepakunni3 Sep 13, 2020
b054998
Fix tabs
justaddcoffee Sep 14, 2020
23f0b3f
Remove extra pip install commands for KGX
justaddcoffee Sep 14, 2020
05cf8d2
Add back pip install stuff
justaddcoffee Sep 14, 2020
0c988d5
Bump python to 3.8
justaddcoffee Sep 14, 2020
9b4160e
Bump python to 3.8 in setup.py
justaddcoffee Sep 14, 2020
9fee4e6
Add version to bmt install
justaddcoffee Sep 14, 2020
ed5184f
Correct version requirement for biolinkml
justaddcoffee Sep 14, 2020
b95b9d9
Try biolinkml version 1.5.7
justaddcoffee Sep 15, 2020
e4d412a
Add wheel to pip install
justaddcoffee Sep 15, 2020
2428135
Bump python requirement in .travis.yaml to 3.8 to match setup.py
justaddcoffee Sep 15, 2020
6a278c1
Merge in master
justaddcoffee Sep 16, 2020
04e687b
Skip transform step for now, for testing merge step
justaddcoffee Sep 16, 2020
b9f28a6
Revert to python3.7
justaddcoffee Sep 16, 2020
0788e24
Fix credentials in transform step
justaddcoffee Sep 16, 2020
6a2d1bf
Fix python version in travis
justaddcoffee Sep 16, 2020
d9a9782
Freeze off raw/ data into build directory
justaddcoffee Sep 16, 2020
10b6b38
Freeze off Jenkinsfile too
justaddcoffee Sep 16, 2020
bc73494
Skip blazegraph journal step for now
justaddcoffee Sep 17, 2020
e052474
add correct check for branch (for testing)
justaddcoffee Sep 17, 2020
63d601f
Remove merge step for faster testing
justaddcoffee Sep 18, 2020
754c6d2
Make data/merged directory during testing
justaddcoffee Sep 18, 2020
a2b8b23
Move gosite GH repo download in Jenkinsfile
justaddcoffee Sep 18, 2020
6c98694
Make sure code gets executed
justaddcoffee Sep 19, 2020
5861461
Fix problem with cloning go-site repo
justaddcoffee Sep 21, 2020
9e45288
Make test stats file
justaddcoffee Sep 21, 2020
a6ce620
Fix cp and mv command to create new_current
justaddcoffee Sep 21, 2020
93cce7c
Add check to fail so as to not nuke existing build dir, and verbose f…
justaddcoffee Sep 21, 2020
3ca5dea
Fix quotes/interpolation bug, add block up top to check
justaddcoffee Sep 21, 2020
ebe268b
Add check up top
justaddcoffee Sep 21, 2020
f479e36
Remove check block
justaddcoffee Sep 21, 2020
b9fb335
Update Jenkinsfile
justaddcoffee Sep 21, 2020
eb8a7a2
Remove test block
justaddcoffee Sep 21, 2020
5a6481e
Add current/ redirect
justaddcoffee Sep 21, 2020
a5a5cb6
Add pip install cmd's for bucket indexer
justaddcoffee Sep 21, 2020
5aaf226
Remove pypandoc install from jenkins
justaddcoffee Sep 21, 2020
2ccbbb1
Why isn't fileExists working
justaddcoffee Sep 21, 2020
2d508e8
Remove --add-header flag to s3cmd
justaddcoffee Sep 21, 2020
6bf5723
Speed up testing
justaddcoffee Sep 21, 2020
ba91faf
Speed up tests
justaddcoffee Sep 21, 2020
a313e0d
Typo
justaddcoffee Sep 21, 2020
017869e
Please please please pip install pystache
justaddcoffee Sep 21, 2020
5184284
Remove pip install pystache
justaddcoffee Sep 21, 2020
281aa5e
Pleading with pip, still
justaddcoffee Sep 21, 2020
1c6ae6a
More pip acrobatics
justaddcoffee Sep 21, 2020
55a1bd5
Running out of ideas for how to get pip to do it's job here
justaddcoffee Sep 21, 2020
e636160
Comment
justaddcoffee Sep 21, 2020
8e496e8
more verbose
justaddcoffee Sep 21, 2020
b452b32
Install pystache
justaddcoffee Sep 21, 2020
d4f4115
Fix path to python
justaddcoffee Sep 21, 2020
3db2f8f
Add boto3
justaddcoffee Sep 21, 2020
5b9ec49
Try to get string interpolation to work
justaddcoffee Sep 21, 2020
759f220
Why isn't S3CMD_JSON being interpolated
justaddcoffee Sep 21, 2020
7f69edd
Try this
justaddcoffee Sep 21, 2020
4b39042
Back it up
justaddcoffee Sep 21, 2020
a554da1
print env
justaddcoffee Sep 21, 2020
1e638d6
Fix credentials string
justaddcoffee Sep 21, 2020
3f7af50
Add aws json variable
justaddcoffee Sep 22, 2020
030cbb6
Build subdirectory index.html's and remove 1 min wait
justaddcoffee Sep 22, 2020
5ba2cea
Fix path
justaddcoffee Sep 22, 2020
86caf0c
Triple dash typo
justaddcoffee Sep 22, 2020
62731bb
Trailing slash
justaddcoffee Sep 22, 2020
1ff3899
Remove trailing slash
justaddcoffee Sep 22, 2020
031177d
Try sync instead of cp for cf invalidation
justaddcoffee Sep 22, 2020
92ca8d9
Fix incorrectly named env var (S3CMD_JSON -> S3CMD_CFG)
justaddcoffee Sep 22, 2020
324f1a9
Change sync to cp
justaddcoffee Sep 22, 2020
d742b5e
Change cp to put
justaddcoffee Sep 22, 2020
47225d1
try --cf-invalidate-default-index
justaddcoffee Sep 22, 2020
de92367
Remove invalidation default index, fix (hopefully) the fileExists check
justaddcoffee Sep 22, 2020
aa2eb8a
Pretty please simon says interpolate my variable
justaddcoffee Sep 22, 2020
1252e29
Check for remote BUILDSTARTDATE dir
justaddcoffee Sep 22, 2020
3bc144d
Rename var
justaddcoffee Sep 22, 2020
a070724
Add check for existing remote dir on s3
justaddcoffee Sep 22, 2020
b0ec150
More checking
justaddcoffee Sep 22, 2020
c5e9744
More messages
justaddcoffee Sep 22, 2020
ef6ca9f
Remove check
justaddcoffee Sep 22, 2020
3b63c5a
Add back if/else for remote checking
justaddcoffee Sep 22, 2020
83db449
Sanity check
justaddcoffee Sep 22, 2020
f3d7522
Please interpolate
justaddcoffee Sep 22, 2020
e9c4542
Try exiting
justaddcoffee Sep 22, 2020
d09e78a
Groovy variables ugh
justaddcoffee Sep 22, 2020
8e56ce1
Groovy variables ugh part 832
justaddcoffee Sep 22, 2020
a49e71e
Groovy variables
justaddcoffee Sep 22, 2020
b1a5629
Groovy variables
justaddcoffee Sep 22, 2020
b84f6d5
Groovy variables
justaddcoffee Sep 22, 2020
97943a2
Groovy variable
justaddcoffee Sep 22, 2020
8a727df
Remove check for local builddir, since this will essentially never be…
justaddcoffee Sep 22, 2020
b6f9ca1
Groovy variable
justaddcoffee Sep 22, 2020
d14ef00
Variable checking
justaddcoffee Sep 22, 2020
395c6c9
fix variable check
justaddcoffee Sep 22, 2020
e931957
Groovy variables
justaddcoffee Sep 22, 2020
9c9b310
possibly fix cf invalidation problem
justaddcoffee Sep 22, 2020
b3bf54a
Set tar.gz, nt and jnl files to their usual names, also set --cf-defa…
justaddcoffee Sep 22, 2020
f7716a6
Add (probably failing) CF invalidation commands
justaddcoffee Sep 22, 2020
a214f51
Install awscli
justaddcoffee Sep 22, 2020
617b3a4
Fix venv issue, remove release distribution ID which is not used
justaddcoffee Sep 22, 2020
e8af5ce
Stop running run.py download for now
justaddcoffee Sep 22, 2020
d294213
Add aws credentials as vars
justaddcoffee Sep 22, 2020
dbb57fb
Formatting/syntax
justaddcoffee Sep 22, 2020
c5a6290
Fix prefix arg to indexer (add $BUILDSTARTDATE)
justaddcoffee Sep 22, 2020
5ca16b1
added -u flag
justaddcoffee Sep 22, 2020
cb8b455
add back current/ build
justaddcoffee Sep 22, 2020
6f97930
fix mv args
justaddcoffee Sep 22, 2020
b200f49
Fix mv args part deux
justaddcoffee Sep 22, 2020
e5eb931
build new_current (not finished yet)
justaddcoffee Sep 23, 2020
b4e12ea
Fix mv arg
justaddcoffee Sep 23, 2020
80e97ee
push to current correctly
justaddcoffee Sep 23, 2020
dc1b7e5
Remove irrelevant comments
justaddcoffee Sep 23, 2020
d091e92
Whitespace
justaddcoffee Sep 23, 2020
adab5cc
Add back download step
justaddcoffee Sep 23, 2020
4ab2da9
Fix download step
justaddcoffee Sep 23, 2020
4b3aac0
Add back transform step
justaddcoffee Sep 23, 2020
c471aa3
Add back merge step
justaddcoffee Sep 23, 2020
726385c
Add back make blazegraph journal step
justaddcoffee Sep 23, 2020
b58d67c
Fix whitespace and comments in Publish stage
justaddcoffee Sep 23, 2020
1c44c50
Add back check for master branch to publish stage
justaddcoffee Sep 23, 2020
f443c9f
Fix whitespace
justaddcoffee Sep 23, 2020
d7e519d
Remove unnecessary touch cmd
justaddcoffee Sep 23, 2020
6b92fd3
Fix whitespace
justaddcoffee Sep 23, 2020
73fb79a
Remove old commented code
justaddcoffee Sep 23, 2020
597a97f
Whitespace
justaddcoffee Sep 23, 2020
8c5337d
Typo
justaddcoffee Sep 23, 2020
c6f024c
Missing close paren
justaddcoffee Sep 23, 2020
f8f31f6
Misplaced comment
justaddcoffee Sep 23, 2020
1bf07fa
Add back 1 min sleep
justaddcoffee Sep 23, 2020
7f4f730
Fix whitespace
justaddcoffee Sep 23, 2020
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
81 changes: 69 additions & 12 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ pipeline {

environment {
BUILDSTARTDATE = sh(script: "echo `date +%Y%m%d`", returnStdout: true).trim()

// Distribution ID for the AWS CloudFront for this branch,
// used solely for invalidations
AWS_CLOUDFRONT_DISTRIBUTION_ID = 'EUVSWXZQBXCFP'
}

options {
Expand Down Expand Up @@ -61,15 +65,15 @@ pipeline {
if (env.BRANCH_NAME != 'master') { // upload raw to s3 if we're on correct branch
echo "Will not push if not on correct branch."
} else {
withCredentials([file(credentialsId: 's3cmd_kg_hub_push_configuration', variable: 'S3CMD_JSON')]) {
sh 's3cmd -c $S3CMD_JSON --acl-public --mime-type=plain/text --cf-invalidate put -r data/raw s3://kg-hub-public-data/'
withCredentials([file(credentialsId: 's3cmd_kg_hub_push_configuration', variable: 'S3CMD_CFG')]) {
sh 's3cmd -c $S3CMD_CFG --acl-public --mime-type=plain/text --cf-invalidate put -r data/raw s3://kg-hub-public-data/'
}
}
} else { // 'run.py download' failed - let's try to download last good copy of raw/ from s3 to data/
withCredentials([file(credentialsId: 's3cmd_kg_hub_push_configuration', variable: 'S3CMD_JSON')]) {
withCredentials([file(credentialsId: 's3cmd_kg_hub_push_configuration', variable: 'S3CMD_CFG')]) {
sh 'rm -fr data/raw || true;'
sh 'mkdir -p data/raw || true'
sh 's3cmd -c $S3CMD_JSON --acl-public --mime-type=plain/text get -r s3://kg-hub-public-data/raw/ data/raw/'
sh 's3cmd -c $S3CMD_CFG --acl-public --mime-type=plain/text get -r s3://kg-hub-public-data/raw/ data/raw/'
}
}
}
Expand Down Expand Up @@ -117,18 +121,71 @@ pipeline {
steps {
dir('./gitrepo') {
script {
// code for building s3 index files
sh 'git clone https://github.com/justaddcoffee/go-site.git'

// make sure we aren't going to clobber existing data on S3
withCredentials([file(credentialsId: 's3cmd_kg_hub_push_configuration', variable: 'S3CMD_CFG')]) {
REMOTE_BUILD_DIR_CONTENTS = sh (
script: 's3cmd -c $S3CMD_CFG ls s3://kg-hub-public-data/$BUILDSTARTDATE/',
returnStdout: true.trim()
)
echo "REMOTE_BUILD_DIR_CONTENTS (THIS SHOULD BE EMPTY): '${REMOTE_BUILD_DIR_CONTENTS}'"
if("${REMOTE_BUILD_DIR_CONTENTS}" != ''){
echo "Will not overwrite existing (---REMOTE S3---) directory: $BUILDSTARTDATE"
sh 'exit 1'
} else {
echo "remote directory $BUILDSTARTDATE is empty, proceeding"
}
}

if (env.BRANCH_NAME != 'master') {
echo "Will not push if not on correct branch."
} else {
withCredentials([file(credentialsId: 's3cmd_kg_hub_push_configuration', variable: 'S3CMD_JSON')]) {
withCredentials([
file(credentialsId: 's3cmd_kg_hub_push_configuration', variable: 'S3CMD_CFG'),
file(credentialsId: 'aws_kg_hub_push_json', variable: 'AWS_JSON'),
string(credentialsId: 'aws_kg_hub_access_key', variable: 'AWS_ACCESS_KEY_ID'),
string(credentialsId: 'aws_kg_hub_secret_key', variable: 'AWS_SECRET_ACCESS_KEY')]) {
//
// make $BUILDSTARTDATE/ directory and sync to s3 bucket
//
sh 'mkdir $BUILDSTARTDATE/'
sh 'cp -p data/merged/merged-kg.nt.gz $BUILDSTARTDATE/kg-covid-19.nt.gz'
sh 'cp -p data/merged/merged-kg.tar.gz $BUILDSTARTDATE/kg-covid-19.tar.gz'
sh 'cp -p merged-kg.jnl.gz $BUILDSTARTDATE/kg-covid-19.jnl.gz'
// transformed data
sh 'rm -fr data/transformed/.gitkeep'
sh 's3cmd -c $S3CMD_JSON --acl-public --mime-type=plain/text --cf-invalidate put -r data/transformed s3://kg-hub-public-data/'
sh 's3cmd -c $S3CMD_JSON --acl-public --mime-type=plain/text --cf-invalidate put data/merged/merged-kg.nt.gz s3://kg-hub-public-data/kg-covid-19.nt.gz'
sh 's3cmd -c $S3CMD_JSON --acl-public --mime-type=plain/text --cf-invalidate put data/merged/merged-kg.tar.gz s3://kg-hub-public-data/kg-covid-19.tar.gz'
sh 's3cmd -c $S3CMD_JSON --acl-public --mime-type=plain/text --cf-invalidate put merged-kg.jnl.gz s3://kg-hub-public-data/kg-covid-19.jnl.gz'
sh 's3cmd -c $S3CMD_JSON --acl-public --mime-type=plain/text --cf-invalidate put *_stats*.yaml s3://kg-hub-public-data/'
sh 's3cmd -c $S3CMD_JSON --acl-public --mime-type=plain/text --cf-invalidate ls s3://kg-hub-public-data/ | grep yaml > yaml_manifests.txt'
sh 's3cmd -c $S3CMD_JSON --acl-public --mime-type=plain/text --cf-invalidate put yaml_manifests.txt s3://kg-hub-public-data/'
sh 'cp -pr data/transformed $BUILDSTARTDATE/'
sh 'cp -pr data/raw $BUILDSTARTDATE/'
sh 'cp Jenkinsfile $BUILDSTARTDATE/'
// stats dir
sh 'mkdir $BUILDSTARTDATE/stats/'
sh 'cp -p *_stats.yaml $BUILDSTARTDATE/stats/'

//
// put $BUILDSTARTDATE/ in s3 bucket
//
sh '. venv/bin/activate && python3.7 ./go-site/scripts/directory_indexer.py -v --inject ./go-site/scripts/directory-index-template.html --directory $BUILDSTARTDATE --prefix https://kg-hub.berkeleybop.io/$BUILDSTARTDATE -x -u'
sh 's3cmd -c $S3CMD_CFG put -pr --acl-public --mime-type=text/html --cf-invalidate $BUILDSTARTDATE s3://kg-hub-public-data/'

// make current/ directory
sh '. venv/bin/activate && python3.7 ./go-site/scripts/directory_indexer.py -v --inject ./go-site/scripts/directory-index-template.html --directory $BUILDSTARTDATE --prefix https://kg-hub.berkeleybop.io/current -x -u'
sh 's3cmd -c $S3CMD_CFG put -pr --acl-public --mime-type=text/html --cf-invalidate $BUILDSTARTDATE/ s3://kg-hub-public-data/current/'

// Build the top level index.html
// "External" packages required to run these
// scripts.
sh './venv/bin/pip install pystache boto3'
sh '. venv/bin/activate && python3.7 ./go-site/scripts/bucket-indexer.py --credentials $AWS_JSON --bucket kg-hub-public-data --inject ./go-site/scripts/directory-index-template.html --prefix https://kg-hub.berkeleybop.io/ > top-level-index.html'
sh 's3cmd -c $S3CMD_CFG put --acl-public --mime-type=text/html --cf-invalidate top-level-index.html s3://kg-hub-public-data/index.html'

// Invalidate the CDN now that the new
// files are up.
sh './venv/bin/pip install awscli'
sh 'echo "[preview]" > ./awscli_config.txt && echo "cloudfront=true" >> ./awscli_config.txt'
sh '. venv/bin/activate && AWS_CONFIG_FILE=./awscli_config.txt python3.7 ./venv/bin/aws cloudfront create-invalidation --distribution-id $AWS_CLOUDFRONT_DISTRIBUTION_ID --paths "/*"'

// Should now appear at:
// https://kg-hub.berkeleybop.io/[artifact name]
}
Expand Down