This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 137
/
Jenkinsfile
70 lines (54 loc) · 1.67 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
#!groovy
@Library('sec_ci_libs@v2-latest') _
env.PROJECT_DIR = '/go/src/github.com/mesosphere/mesos-dns'
ansiColor('xterm') {
node("golang111") {
properties([
parameters([
string(name: "SLACK_CREDENTIAL_ID", defaultValue: "8f0e60ea-1d59-4885-965e-3003bc0a9054"),
string(name: "SLACK_CHANNEL", defaultValue: "#mesos-dns"),
string(name: "ALERTS_FOR_BRANCHES", defaultValue: "master")
])
])
stage("Verify author") {
def alerts_for_branches = params.ALERTS_FOR_BRANCHES.tokenize(",") as String[]
user_is_authorized(alerts_for_branches, params.SLACK_CREDENTIAL_ID, params.SLACK_CHANNEL)
}
deleteDir()
stage("Build and Test") {
dir (env.PROJECT_DIR) {
checkout scm
def packageSHA = getPackageSHA()
def packageVersion = getPackageVersion()
withEnv(["PACKAGE_SHA=${packageSHA}","PACKAGE_VERSION=${packageVersion}"]) {
timeout(30) {
sh("./ci.sh")
}
}
}
junit("test_results/junit/alltests.xml")
archiveArtifacts(artifacts: "target/*")
}
}
}
def getPackageSHA() {
def isPullRequest = (env.CHANGE_ID != null)
if (isPullRequest) {
def parents = sh(
returnStdout: true,
script: "git log --pretty=%P -n 1 HEAD").trim().split()
if (parents.size() != 1) {
// Non fast-forward case.
return parents[0]
}
}
return sh(
returnStdout: true,
script: "git rev-parse HEAD").trim()
}
def getPackageVersion() {
def packageSHA = getPackageSHA()
return sh(
returnStdout: true,
script: "git describe --exact-match ${packageSHA} 2>/dev/null || echo ${packageSHA}").trim()
}