-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsfile
68 lines (65 loc) · 3.12 KB
/
Jenkinsfile
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
// abort existing build
def buildNumber = env.BUILD_NUMBER as int
if (buildNumber > 1) milestone(buildNumber - 1)
milestone(buildNumber)
node('staging') {
configFileProvider([
configFile(fileId:'a9ed1374-1437-4d32-9593-094073a48bca', variable:'CONFIG')
]) {
def props = readProperties file: "$CONFIG"
try {
dir(props.APP_ROOT) {
checkout scm
stage('update backend dependencies') {
bat "$props.VENV_ACTIVATE_CMD && pip install -r requirements.txt"
bat "$props.VENV_ACTIVATE_CMD && python manage.py collectstatic --noinput"
}
stage('run backend unit tests') {
bat "$props.VENV_ACTIVATE_CMD && python manage.py test"
}
// need permissions to create test db
// stage('run backend test') {
// bat ".\\venv\\Scripts\\activate && python manage.py test --noinput"
// }
stage('run migrations') {
bat "$props.VENV_ACTIVATE_CMD && python manage.py migrate"
}
dir('.\\ui') {
withEnv(["PATH=$props.NPM_PATH;$PATH"]) {
stage('update frontend dependencies') {
bat "npm i"
}
stage("build frontend") {
bat "npm run build:ngst-staging"
}
stage("run e2e tests") {
try {
configFileProvider([configFile(fileId: 'be366a0d-7ab7-4d10-84c0-9ae3e5442af5', targetLocation: 'cypress.env.json')]) {
config = readJSON file: 'cypress.env.json'
env.CYPRESS_BASE_URL=config['baseUrl']
env.NO_COLOR=1
bat "npm run e2e"
}
} catch (e) {
archiveArtifacts artifacts:'cypress/videos/**/*.mp4'
throw e
}
}
}
}
}
stage("Approval") {
slackSend(channel:props.NOTIFICATION_CHANNEL_ID, message: "Account Request Tool Staging Build COMPLETE",
teamDomain:'innovateinc', botUser:true, tokenCredentialId:'9de5b95a-9ad8-418a-989e-7ae694f3613f')
input(message: "Approved for merge?")
// todo: revert migrations on abort
}
} catch(Exception e) {
slackSend(channel:props.NOTIFICATION_CHANNEL_ID, message: "Account Request Tool Staging Build FAILED or SUPERSEDED",
teamDomain:'innovateinc', botUser:true, tokenCredentialId:'9de5b95a-9ad8-418a-989e-7ae694f3613f')
slackSend(channel:props.NOTIFICATION_CHANNEL_ID, message: e.message,
teamDomain:'innovateinc', botUser:true, tokenCredentialId:'9de5b95a-9ad8-418a-989e-7ae694f3613f')
throw(e)
}
}
}