-
Notifications
You must be signed in to change notification settings - Fork 335
/
Jenkinsfile
75 lines (64 loc) · 1.9 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
/*
This node works with workflow to cancel all other running builds of the same job
Use case: many build may go to QA and wait in queue, only latest build is important,
the other builds in the workflow are going to be aborted.
*/
slaveNode = 'flutteronly'
node('master') {
def jobname = env.JOB_NAME
def buildnum = env.BUILD_NUMBER.toInteger()
def job = Jenkins.instance.getItemByFullName(jobname)
def list = job.builds
println("***jobname = env.JOB_NAME: " jobname)
println("***buildnum = env.BUILD_NUMBER.toInteger(): " buildnum)
println("***Jenkins.instance.getItemByFullName(jobname): " job)
println("***job.builds.first(): " job.builds.first())
for (build in job.builds) {
if (build.isBuilding() && build != job.builds.first()) {
println '*' * 30
println("***build: " build)
println 'These builds for this job have been aborted!'
println '*' * 30
build.doStop()
}
}
}
/*
Pipeline will get latest code and build stage will perform the build
*/
pipeline {
agent { label slaveNode }
environment {
LC_CTYPE = 'en_US.UTF-8'
PATH = "$PATH:/Users/builder/homebrew/bin:/Users/builder/flutter/bin"
}
stages {
stage('Build') {
steps {
script {
sh '''
flutter packages get
cd example
flutter packages get
cd ..
flutter clean
'''
}
}
}
stage('Testing') {
steps {
sh '''
flutter test
'''
}
}
stage('Analyzing') {
steps {
sh '''
flutter analyze
'''
}
}
}
}