-
Notifications
You must be signed in to change notification settings - Fork 24
/
JenkinsfileDeploy
89 lines (85 loc) · 3.71 KB
/
JenkinsfileDeploy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
pipeline {
agent { label 'notebooks' }
environment {
env_name = "jwst_validation_notebooks"
deploy_branch = "gh-pages"
HOME="${WORKSPACE}"
TEST_BIGDATA="https://bytesalad.stsci.edu/artifactory"
CRDS_SERVER_URL = "https://jwst-crds.stsci.edu"
CRDS_PATH = "/tmp/crds_cache"
PATH ="${WORKSPACE}/miniconda3/bin:${PATH}"
TMPDIR="${WORKSPACE}/tmp"
XDG_CACHE_HOME="${WORKSPACE}/tmp/.cache"
}
stages {
stage('Setup') {
steps {
deleteDir()
checkout scm
script {
PIPELINE_VERSION = readFile('pipeline_version.txt').trim()
}
sh("mkdir -p tmp")
sh("curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o installer.sh")
sh("bash installer.sh -b -p ${WORKSPACE}/miniconda3")
sh("curl -LO https://raw.githubusercontent.com/astroconda/docker-buildsys/master/with_env")
sh("chmod +x with_env")
sh("conda create -n ${env_name} --file https://ssb.stsci.edu/releases/jwstdp/${PIPELINE_VERSION}/conda_python_stable-deps.txt")
sh("./with_env -n ${env_name} pip install -r https://ssb.stsci.edu/releases/jwstdp/${PIPELINE_VERSION}/reqs_stable-deps.txt")
sh("conda env update --name ${env_name} --file notebook_supplement.yml --prune --verbose")
}
}
stage('Convert/Check') {
steps {
sh("./with_env -n ${env_name} python convert.py --notebook-path jwst_validation_notebooks --report report.txt")
sh("./with_env -n ${env_name} python prepend_date.py --reportfile report.xml")
sh("""
cd jwst_validation_notebooks
../with_env -n ${env_name} python -m 'nbpages.check_nbs'
""")
}
}
stage('Deploy') {
steps {
script {
if(env.JOB_NAME.toLowerCase().contains('pr')) {
echo "Pull Request, Not deploying..."
} else {
echo "Deploying to Github Pages"
sh("git clone -b ${deploy_branch} --single-branch [email protected]:spacetelescope/jwst_validation_notebooks.git notebooks_clone")
dir('./notebooks_clone'){
sh("""cp -aR ${env.WORKSPACE}/jwst_validation_notebooks/* ./jwst_validation_notebooks/
cp ${env.WORKSPACE}/index.html ./index.html
ls ./jwst_validation_notebooks/
git config --global user.email [email protected]
git config --global user.name jenkins-deploy
echo "Status before adding current directory"
git status
git add .
echo "Status after adding current directory"
git status
git commit -m 'Automated deployment to GitHub Pages: ${env.BUILD_TAG}' --allow-empty
git remote add deploy ssh://[email protected]/spacetelescope/jwst_validation_notebooks.git
git push deploy ${deploy_branch}
cd ${env.WORKSPACE}
chmod ug=rwx index.html
find . -name "*.html" | xargs chmod ug=rwx
rsync -vH index.html ${env.WEBPAGE_DIR}
find . -name "*.html" -print >html_files
rsync -vHR --files-from=html_files . ${env.WEBPAGE_DIR}
""")
deleteDir()
} // end of stuff happening in notebooks_clone
echo "Creating webpage archive on central storage"
sh("./with_env -n ${env_name} python archive.py")
}
} // end of script
} // end of deploy steps
} // end of deploy stage
} // end of stages
post {
cleanup {
deleteDir()
} //end of cleanup
} //end of post
} // end of pipeline