-
Notifications
You must be signed in to change notification settings - Fork 0
/
.jenkins-4-upgrade-stage-to-prod
67 lines (57 loc) · 2.34 KB
/
.jenkins-4-upgrade-stage-to-prod
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
/*
* This groovy script will be triggered by remote script to automatically update
* pull the latest master branch to the PROD deployment env and restart the APIs
* Job Triggered: 'jenkins-4-upgrade-stage-to-prod'
*/
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'START BUILD ...'
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/dwd-umd/catch-apis.git']]])
sh '''
cat .jenkins-testing
'''
echo "... END BUILD"
}
}
stage('Test') {
steps {
echo 'START TESTING ...'
sh '''
# python3 -m venv .venv
# source .venv/bin/activate
# pip install pytest requests
# sh _run_tests # Add argument 'fail' in order test failing
'''
// junit 'pytest_unit.xml'
echo "... END TESTING"
}
}
stage('Deploy') {
steps {
echo "START DEPLOYING ..."
sh '''
cd $CATCH_PROD_APIS_PATH # Global env var (go to 'Manage Jenkins > Configure System > Global properties' and add vars)
pwd
git stash
git pull origin master
# Ensure nvm is initialized (npm needed for _worker_manager below)
. $NVM_INIT_SCRIPT || true
. $CATCH_PROD_APIS_PATH/_initial_setup jenkins
# Must set this env for daemon to survive pipeline's termination
JENKINS_NODE_COOKIE=dontKillMe bash ./_gunicorn_manager restart
JENKINS_NODE_COOKIE=dontKillMe bash ./_worker_manager restart
# Create time-stamped files for debugging
#touch "hello-`date +%Y-%m-%d`.txt"
#touch "hello-`date`.txt"
sleep 5
# Try pinging url for catch-prod
curl localhost:5000/catch/demo
echo "... END DEPLOYING"
'''
}
}
}
}