-
Notifications
You must be signed in to change notification settings - Fork 1
/
jenkins.groovy
51 lines (50 loc) · 2.67 KB
/
jenkins.groovy
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
// This is the hourly cron script that Jenkins will execute.
node('linux') {
stage('checkout'){
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '61235359-4c9e-4d64-b63a-7717e51f3069', url: 'https://github.com/PennyDreadfulMTG/Penny-Dreadful-Tools.git']]])
}
stage('setup') {
try{
sh 'python3 -m pip install --user -r requirements.txt'
} catch (Exception e) {
currentBuild.result = 'UNSTABLE'
}
withCredentials([usernamePassword(credentialsId: 'd61f34a1-4929-406d-b4c5-ec380d823780', passwordVariable: 'github_password', usernameVariable: 'github_user')]) {
sh 'python3 run.py modo_bugs init'
dir('modo_bugs_repo') {
sh 'git config user.email "[email protected]"'
sh 'git config user.name "Vorpal Buildbot"'
sh 'git checkout master'
sh 'git pull'
}
}
}
stage('Scrape') {
withCredentials([usernamePassword(credentialsId: 'd61f34a1-4929-406d-b4c5-ec380d823780', passwordVariable: 'github_password', usernameVariable: 'github_user'), usernamePassword(credentialsId: 'modo_bugs_webhook_id_and_token', passwordVariable: 'bugs_webhook_token', usernameVariable: 'bugs_webhook_id')]) {
sh returnStatus: true, script: 'python3 run.py modo_bugs scrape_bb'
sh returnStatus: true, script: 'python3 run.py modo_bugs scrape_an'
}
}
stage('Update'){
withCredentials([usernamePassword(credentialsId: 'd61f34a1-4929-406d-b4c5-ec380d823780', passwordVariable: 'github_password', usernameVariable: 'github_user')]) {
sh 'python3 run.py modo_bugs update'
}
}
stage('Verification') {
withCredentials([usernamePassword(credentialsId: 'd61f34a1-4929-406d-b4c5-ec380d823780', passwordVariable: 'github_password', usernameVariable: 'github_user')]) {
sh returnStatus: true, script: 'python3 run.py modo_bugs verify'
}
}
stage('Push changes'){
dir('modo_bugs_repo') {
def updated = sh returnStatus: true, script: 'git diff --exit-code'
if (updated){
sh 'git commit -a -m "Updated Bug List from Issues"'
sh 'git pull'
}
withCredentials([usernamePassword(credentialsId: 'd61f34a1-4929-406d-b4c5-ec380d823780', passwordVariable: 'github_password', usernameVariable: 'github_user')]) {
sh 'git push https://$github_user:[email protected]/PennyDreadfulMTG/modo-bugs.git'
}
}
}
}