-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Jenkinsfile
155 lines (140 loc) · 5.98 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
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
149
150
151
152
153
154
155
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
Test modules and groups.
Use command "mvn -fae -Dexec.executable='echo' -Dexec.args='${project.artifactId}' exec:exec -q" to revisit
Ambari WebUI -> ambari-web, ambari-admin
Ambari Agent -> ambari-agent, ambari-utility
Ambari Server -> ambari-server, ambari-views
Ambari Metrics -> (cd) -> ambari-metrics (only build, no checks)
ServiceAdvisor -> ambari-serviceadvisor
Ambari LogSearch -> (cd) -> ambari-logsearch
Ambari Infra -> (cd) -> ambari-infra
Ambari Server JTest Profiles: FastTests, SlowTests, NonFastTests, AlertTests, AmbariUpgradeTests, BlueprintTests, KerberosTests, MetricsTests, StackUpgradeTests
Jenkins Plugins required:
- JIRA Steps, https://plugins.jenkins.io/jira-steps/
- Jenkins Multibranch pipeline
**/
pipeline {
agent {
node {
label 'Hadoop'
}
}
tools {
maven 'maven_3_latest'
jdk 'jdk_1.8_latest'
}
environment {
TEMP='/tmp'
TEMPDIR='/tmp'
TMP='/tmp'
TMPDIR='/tmp'
}
stages {
stage('Pre-Build Deps') {
parallel{
stage('JIRA Integration') {
steps {
publishPRLink env.CHANGE_ID, env.CHANGE_URL, env.CHANGE_TITLE
}
}
stage('Ambari Metrics Build (deps)') {
steps {
script{
def dirExists = fileExists 'ambari-metrics'
if (dirExists) {
echo "Ambari-Metrics is here!"
dir('ambari-metrics') {
sh 'mvn -T 3C install -DskipSurefireTests -DskipPythonTests -Dmaven.test.failure.ignore -DskipTests -Dfindbugs.skip -Drat.skip -Dmaven.artifact.threads=10 -X'
}
} else {
echo "Ignoring ambari-metrics, as no such directory found"
}
}
}
}
stage('Ambari Service Advisor') {
steps {
sh 'mvn -T 3C -am install -pl ambari-serviceadvisor -DskipSurefireTests -DskipPythonTests -Dmaven.test.failure.ignore -DskipTests -Dfindbugs.skip -Drat.skip -Dmaven.artifact.threads=10'
}
}
}
}
// Rat & Checkstyle is not really like multi-threading due to high possiblity of false possitives.
stage('RAT') {
steps{
sh 'mvn org.apache.rat:apache-rat-plugin:check -Dmaven.artifact.threads=10'
}
}
stage('Parallel Unit Tests') {
parallel {
stage('Ambari Agent Tests') {
steps {
sh 'pip3 install distro'
sh 'mvn -Dmaven.test.failure.ignore=true -am test -pl ambari-agent -Dmaven.artifact.threads=10 -Drat.skip'
}
}
stage('Ambari Server PyTests') {
steps {
sh 'mvn clean -am test -pl ambari-server -DskipSurefireTests -Dmaven.test.failure.ignore -Dmaven.artifact.threads=10 -Drat.skip -Dcheckstyle.skip -DskipAdminWebTests=true'
}
}
}
}
stage('Ambari WebUI Tests') {
steps {
withEnv(['CHROME_BIN=/usr/bin/chromium-browser']) {
sh 'mvn -T 2C -am test -pl ambari-web,ambari-admin -Dmaven.artifact.threads=10 -Drat.skip'
}
}
}
stage('Ambari Server JTests') {
steps {
sh 'mvn -am test -pl ambari-server -DskipPythonTests -Dmaven.test.failure.ignore -Dmaven.artifact.threads=10 -Drat.skip -DskipAdminWebTests=true'
}
}
}
}
@NonCPS
def publishPRLink(change_id, change_url, change_title) {
println "Change id: $change_id, title: $change_title, url: $change_url"
def jira_num = change_title =~ /(?i)^\[*(?<JIRA>AMBARI\-\d+)/
jira_num = jira_num.find() ? jira_num.group("JIRA") : ""
println "JIRA ID: $jira_num"
if (jira_num) {
// tip: https://developer.atlassian.com/server/jira/platform/jira-rest-api-for-remote-issue-links/
// globalId is required for JIRA to distinguish 2 same links and do not stack new objects
def remoteLink = [
globalId : "system=$change_url",
object : [url : change_url,
title: "GitHub PR#$change_id",
icon : [
url16x16: "https://github.com/favicon.ico",
title : "GitHub PR#$change_id"
]
]
]
jiraNewIssueRemoteLink idOrKey: jira_num, remoteLink: remoteLink, site: "JIRA"
} else {
println """
======failed to add link to jira
Ooops, no jira id found :(
============================="""
pullRequest.comment("Pull request summary '${change_title}' doesn't contain JIRA Number in format 'AMBARI-xxxxx' at the beginning, please, create the JIRA issue and update pull request summary")
}
}