From 6e7c1cfdf3a70ef9a189c084f2001a4e6b63ed57 Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Wed, 17 Jul 2019 12:31:17 +0200 Subject: [PATCH] Support py3-master_gpu_doc CI run on arbitrary branches (#834) --- ci/jenkins/Jenkinsfile_py3-master_gpu_doc | 76 +++++++++++++++-------- 1 file changed, 51 insertions(+), 25 deletions(-) diff --git a/ci/jenkins/Jenkinsfile_py3-master_gpu_doc b/ci/jenkins/Jenkinsfile_py3-master_gpu_doc index 5718200fe9..693effd560 100644 --- a/ci/jenkins/Jenkinsfile_py3-master_gpu_doc +++ b/ci/jenkins/Jenkinsfile_py3-master_gpu_doc @@ -63,48 +63,74 @@ core_logic: { // The converted notebooks and the conversion logs are // saved to S3 and retrieved on the CI server once the jobs // finished. - sh """ - set +e - conda activate ./conda/cpu/py3 - if [ '${env.BRANCH_NAME}' = 'master' ]; then + if (env.BRANCH_NAME.startsWith('PR-')){ + sh """ + set +e + conda activate ./conda/cpu/py3 + python3 ci/batch/submit-job.py --region us-east-1 --wait \ --timeout 1800 --saved-output ./docs/examples --conda-env docker/py3 \ --name GluonNLP-${env.BRANCH_NAME}-${env.BUILD_NUMBER} \ --save-path batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/docs/examples \ - --work-dir . \ + --work-dir . --source-ref refs/pull/${env.CHANGE_ID}/head \ --command \"python3 docs/md2ipynb.py ${md_file} > ${stdout_file} 2> ${stderr_file} \" BATCH_EXIT_CODE=\$? - else + + aws s3api wait object-exists --bucket gluon-nlp-staging \ + --key batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${stderr_file} + aws s3 cp s3://gluon-nlp-staging/batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${stderr_file} ${stderr_file} + cat ${stderr_file} + + aws s3api wait object-exists --bucket gluon-nlp-staging \ + --key batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${stdout_file} + aws s3 cp s3://gluon-nlp-staging/batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${stdout_file} ${stdout_file} + cat ${stdout_file} + + if [ \$BATCH_EXIT_CODE -ne 0 ]; then + echo AWS Batch Task Failed + else + aws s3api wait object-exists --bucket gluon-nlp-staging \ + --key batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${ipynb_file} + aws s3 cp s3://gluon-nlp-staging/batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${ipynb_file} ${ipynb_file} + fi + + exit \$BATCH_EXIT_CODE + """ + } else { + sh """ + set +e + conda activate ./conda/cpu/py3 + python3 ci/batch/submit-job.py --region us-east-1 --wait \ --timeout 1800 --saved-output ./docs/examples --conda-env docker/py3 \ --name GluonNLP-${env.BRANCH_NAME}-${env.BUILD_NUMBER} \ --save-path batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/docs/examples \ - --work-dir . --source-ref refs/pull/${env.CHANGE_ID}/head \ + --work-dir . --source-ref ${env.BRANCH_NAME} \ --command \"python3 docs/md2ipynb.py ${md_file} > ${stdout_file} 2> ${stderr_file} \" BATCH_EXIT_CODE=\$? - fi - aws s3api wait object-exists --bucket gluon-nlp-staging \ - --key batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${stderr_file} - aws s3 cp s3://gluon-nlp-staging/batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${stderr_file} ${stderr_file} - cat ${stderr_file} - - aws s3api wait object-exists --bucket gluon-nlp-staging \ - --key batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${stdout_file} - aws s3 cp s3://gluon-nlp-staging/batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${stdout_file} ${stdout_file} - cat ${stdout_file} + aws s3api wait object-exists --bucket gluon-nlp-staging \ + --key batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${stderr_file} + aws s3 cp s3://gluon-nlp-staging/batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${stderr_file} ${stderr_file} + cat ${stderr_file} - if [ \$BATCH_EXIT_CODE -ne 0 ]; then - echo AWS Batch Task Failed - else aws s3api wait object-exists --bucket gluon-nlp-staging \ - --key batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${ipynb_file} - aws s3 cp s3://gluon-nlp-staging/batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${ipynb_file} ${ipynb_file} - fi + --key batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${stdout_file} + aws s3 cp s3://gluon-nlp-staging/batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${stdout_file} ${stdout_file} + cat ${stdout_file} + + if [ \$BATCH_EXIT_CODE -ne 0 ]; then + echo AWS Batch Task Failed + else + aws s3api wait object-exists --bucket gluon-nlp-staging \ + --key batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${ipynb_file} + aws s3 cp s3://gluon-nlp-staging/batch/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/${ipynb_file} ${ipynb_file} + fi - exit \$BATCH_EXIT_CODE - """ + exit \$BATCH_EXIT_CODE + """ + } } } }