forked from nrfconnect/sdk-mcuboot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
82 lines (77 loc) · 2.45 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
def IMAGE_TAG = "ncs-toolchain:1.07"
def REPO_CI_TOOLS = "https://github.com/zephyrproject-rtos/ci-tools.git"
pipeline {
agent {
docker {
image "$IMAGE_TAG"
label "docker && build-node && ncs"
}
}
options {
// Checkout the repository to this folder instead of root
checkoutToSubdirectory('mcuboot')
}
environment {
// This token is used to by check_compliance to comment on PRs and use checks
GH_TOKEN = credentials('nordicbuilder-compliance-token')
GH_USERNAME = "NordicBuilder"
COMPLIANCE_SCRIPT_PATH = "../ci-tools/scripts/check_compliance.py"
COMPLIANCE_ARGS = "-r NordicPlayground/fw-nrfconnect-mcuboot"
COMPLIANCE_REPORT_ARGS = "-p $CHANGE_ID -S $GIT_COMMIT -g"
}
stages {
stage('Checkout repositories') {
steps {
dir("ci-tools") {
git branch: "master", url: "$REPO_CI_TOOLS"
}
}
}
stage('Run compliance check') {
steps {
dir('mcuboot') {
script {
// If we're a pull request, compare the target branch against the current HEAD (the PR)
if (env.CHANGE_TARGET) {
COMMIT_RANGE = "origin/${env.CHANGE_TARGET}..HEAD"
COMPLIANCE_ARGS = "$COMPLIANCE_ARGS $COMPLIANCE_REPORT_ARGS"
}
// If not a PR, it's a non-PR-branch or master build. Compare against the origin.
else {
COMMIT_RANGE = "origin/${env.BRANCH_NAME}..HEAD"
}
// Run the compliance check
try {
sh "$COMPLIANCE_SCRIPT_PATH $COMPLIANCE_ARGS --commits $COMMIT_RANGE"
}
finally {
junit 'compliance.xml'
archiveArtifacts artifacts: 'compliance.xml'
}
}
}
}
}
}
post {
always {
// Clean up the working space at the end (including tracked files)
cleanWs()
}
failure {
script{
if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME.startsWith("PR"))
{
emailext(to: 'anpu',
body: "${currentBuild.currentResult}\nJob ${env.JOB_NAME}\t\t build ${env.BUILD_NUMBER}\r\nLink: ${env.BUILD_URL}",
subject: "[Jenkins][Build ${currentBuild.currentResult}: ${env.JOB_NAME}]",
mimeType: 'text/html',)
}
else
{
echo "Branch ${env.BRANCH_NAME} is not master nor PR. Sending failure email skipped."
}
}
}
}
}