forked from DrSnowbird/amf
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsfile
More file actions
148 lines (145 loc) · 4.13 KB
/
Jenkinsfile
File metadata and controls
148 lines (145 loc) · 4.13 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!groovy
def slackChannel = '#amf-jenkins'
def failedStage = ""
def color = '#FF8C00'
def headerFlavour = "WARNING"
pipeline {
agent {
dockerfile true
}
environment {
NEXUS = credentials('exchange-nexus')
NEXUSIQ = credentials('nexus-iq')
}
stages {
stage('Test') {
steps {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
script {
try{
sh 'sbt -mem 4096 -Dfile.encoding=UTF-8 clean coverage test coverageReport'
} catch (ignored) {
failedStage = failedStage + " TEST "
unstable "Failed tests"
}
}
}
}
}
stage('Coverage') {
when {
anyOf {
branch 'master'
branch 'develop'
}
}
steps {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'sonarqube-official', passwordVariable: 'SONAR_SERVER_TOKEN', usernameVariable: 'SONAR_SERVER_URL']]) {
script {
try {
if (failedStage.isEmpty()) {
sh 'sbt -Dsonar.host.url=${SONAR_SERVER_URL} sonarScan'
}
} catch (ignored) {
failedStage = failedStage + " COVERAGE "
unstable "Failed coverage"
}
}
}
}
}
}
stage('Publish') {
when {
anyOf {
branch 'master'
branch 'develop'
branch 'release/*'
}
}
steps {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
script {
try{
if (failedStage.isEmpty()) {
sh 'sbt publish'
}
} catch(ignored) {
failedStage = failedStage + " PUBLISH "
unstable "Failed publication"
}
}
}
}
}
stage('Nexus IQ') {
when {
anyOf {
branch 'develop'
}
}
steps {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
script {
try{
if (failedStage.isEmpty()){
sh './gradlew nexusIq'
}
} catch(ignored) {
failedStage = failedStage + " NEXUSIQ "
unstable "Failed Nexus IQ"
}
}
}
}
}
stage('Trigger amf projects') {
when {
branch 'develop'
}
steps {
script {
try {
if (failedStage.isEmpty()){
echo "Starting TCKutor Applications/AMF/amfTCKutor/master"
build job: 'application/AMF/amfTCKutor/master', wait: false
echo "Starting TCKutor Applications/AMF/amfexamples/master"
build job: 'application/AMF/amf-examples/snapshot', wait: false
echo "Starting TCKutor Applications/AMF/amfinterfacetests/master"
build job: 'application/AMF/amf-interface-tests/master', wait: false
}
} catch(ignored) {
failedStage = failedStage + " TCKUTOR "
unstable "Failed TCKUTOR job trigger"
}
}
}
}
stage("Report to Slack") {
when {
anyOf {
branch 'master'
branch 'develop'
branch 'release/*'
}
}
steps {
script {
if (!failedStage.isEmpty()) {
if (env.BRANCH_NAME == 'master') {
color = '#FF0000'
headerFlavour = "RED ALERT"
} else if (env.BRANCH_NAME == 'devel') {
color = '#FFD700'
}
slackSend color: color, channel: "${slackChannel}", message: ":alert: ${headerFlavour}! :alert: Build failed!. \n\tBranch: ${env.BRANCH_NAME}\n\tStage:${failedStage}\n(See ${env.BUILD_URL})\n"
currentBuild.status = "FAILURE"
} else if (env.BRANCH_NAME == 'master') {
slackSend color: '#00FF00', channel: "${slackChannel}", message: ":ok_hand: Master Publish OK! :ok_hand:"
}
}
}
}
}
}