-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
153 lines (139 loc) · 4.19 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
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
def ASMCOV_URI
node {
ASMCOV_URI = ''
script {
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl.class,
Jenkins.instance,
null,
null
);
def jenkins_asmcov_uri = creds.findResult { it.id == 'jenkins_asmcov_uri' ? it : null }
if(jenkins_asmcov_uri) {
println(jenkins_asmcov_uri.id + ": " +jenkins_asmcov_uri.username + ": " + jenkins_asmcov_uri.password)
ASMCOV_URI=jenkins_asmcov_uri.password
}
}
}
properties([gitLabConnection('GitLab')])
pipeline {
options {
gitlabBuilds(builds: ["cmocka_extensions", "build debug", "build release", "lint sources", "documentation"])
buildDiscarder(logRotator(numToKeepStr: env.BRANCH_NAME == "master"? "1000": env.BRANCH_NAME == "integration"?"1000":"3"))
}
agent {
dockerfile {
filename './ci/Dockerfile'
reuseNode true
additionalBuildArgs "--build-arg USER=jenkins \
--build-arg UID=\$(id -u) --build-arg GID=\$(id -g) --build-arg ASMCOV_URI=${ASMCOV_URI}"
args '--privileged --userns=keep-id'
label "podman"
}
}
stages {
stage('debug') {
steps{
sh 'ls -lah'
sh 'env'
sh 'gcc --version'
sh 'cmake --version'
updateGitlabCommitStatus name: 'cmocka_extensions', state: 'running'
}
}
stage('Build') {
steps {
parallel(
debug: {
gitlabCommitStatus("build debug") {
sh '''#!/bin/bash -xe
./ci/build.sh --ci Debug
'''
}
},
release: {
gitlabCommitStatus("build release") {
sh '''#!/bin/bash -xe
./ci/build.sh --ci Release
'''
}
}
)
}
}
stage('Lint sources') {
steps{
gitlabCommitStatus("lint sources") {
sh '''#!/bin/bash -xe
export UNUSED_SOURCES="\
"
./ci/code_lint.py --ci --result-dir=build/Release/result/lint_results
./ci/checklicense.sh
'''
}
}
post {
always {
archiveArtifacts artifacts: "build/Release/result/lint_results/**", fingerprint: true
}
}
}
stage('Build documentation') {
steps{
gitlabCommitStatus("documentation") {
sh './ci/build_doc.sh'
}
}
post {
success {
archiveArtifacts artifacts: "build/Debug/doc/**, documentation/monitor.md", fingerprint: true
}
}
}
}
post {
changed {
script {
def jobName = env.JOB_NAME.tokenize('/') as String[];
def projectName = jobName[0];
def title = '[' + projectName + '] '
def message = '';
if (currentBuild.currentResult == 'FAILURE') {
title += 'Pipeline for ' + env.BRANCH_NAME + ' has failed';
message = 'Hi, sorry but the pipeline is broken. See ' + env.BUILD_URL + ' for details.'
}
if(currentBuild.currentResult == 'SUCCESS') {
title += 'Pipeline for ' + env.BRANCH_NAME + ' is now stable again';
message = 'Hi, the pipeline is now stable again. See ' + env.BUILD_URL + ' for details.'
}
emailext subject: title,
body: message,
recipientProviders: [
[$class: 'CulpritsRecipientProvider'],
[$class: 'DevelopersRecipientProvider'],
[$class: 'RequesterRecipientProvider']
],
replyTo: '$DEFAULT_REPLYTO',
to: '$DEFAULT_RECIPIENTS'
}
}
success {
updateGitlabCommitStatus name: 'cmocka_extensions', state: 'success'
}
failure {
updateGitlabCommitStatus name: 'cmocka_extensions', state: 'failed'
}
always {
cleanWs(cleanWhenNotBuilt: false,
deleteDirs: true,
disableDeferredWipeout: true,
notFailBuild: true,
patterns: [[pattern: '.gitignore', type: 'INCLUDE'],
[pattern: '.trace', type: 'INCLUDE']])
}
}
}