forked from Unity-Technologies/unity-ads-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
103 lines (94 loc) · 3.69 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
98
99
100
101
102
103
pipeline {
agent { label "ads_sdk_worker" }
stages {
stage('Setup') {
when {
expression { env.BRANCH_NAME =~ /^PR-/ }
}
steps {
script {
def isPRcommit = (env.BRANCH_NAME =~ /^PR-/)
if (!isPRcommit) {
currentBuild.result = 'ABORTED'
error("\n\n== This is not a PR commit. Not running tests. ==\n\n")
}
}
dir('sharedLibs') {
checkout(
[$class: 'GitSCM', branches: [[name: 'master']],
userRemoteConfigs: [[credentialsId: 'applifier-readonly-jenkins-bot',
url: 'https://github.com/Applifier/unity-ads-sdk-tests.git']]]
)
script {
sharedLibs = load 'sharedLibs.groovy'
}
}
}
}
stage('Run tests') {
when {
expression { env.BRANCH_NAME =~ /^PR-/ }
}
parallel {
stage ('hybrid_test') {
steps {
dir('results') {
script {
def jobName = "ads-sdk-hybrid-test-ios"
def build_ = build(
job: "Applifier/unity-ads-sdk-tests/$jobName",
propagate: false,
wait: true,
parameters: [
string(name: 'UNITY_ADS_IOS_BRANCH', value: env.CHANGE_BRANCH),
]
)
def artifactFolder = "$jobName/$build_.number"
dir(jobName) {
sharedLibs.downloadFromGcp("$artifactFolder/*")
}
try {
sharedLibs.removeFromGcp(artifactFolder)
} catch(e) {
echo "Could not clean up artifacts from GCP: '$e'"
}
}
}
}
}
stage('system_test') {
steps {
dir('results') {
script {
def jobName = "ads-sdk-systest-ios"
build(
job: "Applifier/unity-ads-sdk-tests/$jobName",
propagate: false,
wait: false,
parameters: [
string(name: 'UNITY_ADS_IOS_BRANCH', value: env.CHANGE_BRANCH)
],
)
}
}
}
}
}
}
stage('Post steps') {
when {
expression { env.BRANCH_NAME =~ /^PR-/ }
}
steps {
script {
archiveArtifacts artifacts: "results/**", fingerprint: true
step ([$class: "JUnitResultArchiver", testResults: "results/**/*.xml"])
script {
slackChannel = "ads-sdk-notify"
sharedLibs.sendTestSummary(slackChannel)
}
}
}
}
}
}