-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
101 lines (88 loc) · 2.27 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
#!groovy
import groovy.json.JsonOutput
def notifySlack(text, channel)
{
def slackURL = 'B573SB58E/fVfVRGC31KZfvFAmzLLgOrSu$(SLACK_URL)/B573SB58E/fVfVRGC31KZfvFAmzLLgOrSu'
def payload = JsonOutput.toJson([text: text,
channel : channel,
username : "jenkins",
icon_emoji: ":jenkins:"])
sh "curl -X POST --data-urlencode \'payload=${payload}\' ${slackURL}"
}
def checkoutSource()
{
// Checkout code from repository
checkout scm
// clean git repo, remove untracked files and git ignored files.
sh 'git clean -fdx'
}
def build ()
{
try
{
// build fails after 5 minutes
timeout(5)
{
// make sure to have no colored output - pipeline fails otherwise
withEnv(['FASTLANE_DISABLE_COLORS=1'])
{
sh 'fastlane build'
}
}
}
catch (e)
{
currentBuild.result = 'FAILURE'
notifySlack("Jenkins job <${env.BUILD_URL}|${env.JOB_NAME} ${env.BUILD_DISPLAY_NAME}> failed while building.", "build")
throw e
}
}
def test ()
{
try
{
timeout(5)
{
dir('whisper-iOS')
{
withEnv(['FASTLANE_DISABLE_COLORS=1'])
{
sh 'fastlane test'
}
}
}
}
catch (e)
{
currentBuild.result = 'FAILURE'
notifySlack("Jenkins job <${env.BUILD_URL}|${env.JOB_NAME} ${env.BUILD_DISPLAY_NAME}> failed while testing.", "build")
throw e
}
}
def afterTests()
{
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'whisper-iOS/fastlane/test_output', reportFiles: 'report.html,report.junit', reportName: 'Test results'])
}
print 'build started, trying to reserve an iOS node'
// reserve a specific node with label
node('iOS')
{
stage('Checkout')
{
checkoutSource()
}
stage('Build')
{
build()
}
stage('Test')
{
test()
}
stage('Publish')
{
afterTests()
}
}
print 'setting build cleaning key'
properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '5']]]);