-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
97 lines (77 loc) · 2.6 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
@Library('pipeline-utils')_ // it's not a typo
def staging_url = "https://payment-examples.staging.oregon.platform-os.com"
pipeline {
agent any
environment {
MPKIT_TOKEN = credentials('POS_TOKEN')
MPKIT_EMAIL = "darek+ci@near-me.com"
}
parameters {
string(description: 'Instance URL. When empty then we deploy on staging and production', name: 'MP_URL', defaultValue: '')
}
options {
disableConcurrentBuilds()
timeout(time: 60, unit: 'MINUTES')
}
stages {
stage('Deploy to URL') {
when { expression { return !params.MP_URL.isEmpty() } }
environment { MPKIT_URL = "${params.MP_URL}" }
agent { docker { image 'platformos/marketplace-kit' } }
steps {
sh 'marketplace-kit deploy'
}
}
stage('Test on URL') {
when { expression { return !params.MP_URL.isEmpty() } }
agent { docker { image "platformos/testcafe" } }
environment { MP_URL = "${params.MP_URL}" }
steps {
sh 'npm run test-ci'
}
post { failure { archiveArtifacts "screenshots/" } }
}
stage('Deploy staging') {
agent { docker { image 'platformos/marketplace-kit' } }
environment {
MPKIT_URL = "${staging_url}"
}
when {
expression { return params.MP_URL.isEmpty() }
anyOf { branch 'master' }
}
steps {
sh 'marketplace-kit deploy'
}
}
stage('Test Staging') {
agent { docker { image "platformos/testcafe" } }
environment {
MP_URL = "${staging_url}"
}
when {
expression { return params.MP_URL.isEmpty() }
anyOf { branch 'master' }
}
steps {
sh 'npm run test-ci'
}
post { failure { archiveArtifacts "screenshots/" } }
}
}
post {
success {
slackSend (channel: "#staging_sanity_check", color: '#00FF00', message: "SUCCESS Payments Example: <${env.BUILD_URL}|Build #${env.BUILD_NUMBER}> - ${buildDuration()}. ${commitInfo()}")
}
failure {
slackSend (channel: "#staging_sanity_check", color: '#FF0000', message: "FAILED Payments Example: <${env.BUILD_URL}|Open build details> - ${buildDuration()}")
}
}
}
def commitInfo() {
GH_URL = "https://github.com/mdyd-dev/platformos-payment-examples"
def commitSha = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
// def commitAuthor = sh(returnStdout: true, script: 'git log --no-merges --format="%an" -1').trim()
def commitMsg = sh(returnStdout: true, script: 'git log --no-merges --format="%B" -1 ${commitSha}').trim()
return "<${GH_URL}/commit/${commitSha}|${commitSha} ${commitMsg}>"
}