forked from eclipse-epsilon/epsilon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
191 lines (187 loc) · 7.3 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
@NonCPS
def getSlackMessage() {
def duration = currentBuild.durationString.minus(" and counting")
def message = "Build <${env.BUILD_URL}|#${env.BUILD_NUMBER}> of <https://github.com/eclipse/epsilon/tree/${env.BRANCH_NAME}|${currentBuild.fullProjectName}> "
message += (currentBuild.currentResult == "SUCCESS" ? "passed" : "failed") + " in ${duration}\n\n"
for (changeSet in currentBuild.changeSets) {
for (entry in changeSet.items) {
message += "`${entry.commitId.take(7)}` ${entry.msg} - ${entry.author}\n"
}
}
return message
}
def plainTriggers = '(plugins\\/.*)|(pom[-]plain[.]xml)|(Jenkinsfile)'
def baseTriggers = "${plainTriggers}|(pom\\.xml)"
def updateTriggers = "${baseTriggers}|(standalone\\/.*)|(features\\/.*)|(releng\\/.*(target|updatesite)\\/.*)"
pipeline {
agent {
kubernetes {
label 'migration'
}
}
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '2', daysToKeepStr: '14', numToKeepStr: ''))
}
tools {
maven 'apache-maven-3.9.5'
jdk 'openjdk-jdk17-latest'
}
triggers {
pollSCM('H/5 * * * *')
}
stages {
stage('Main') {
stages {
stage('Build') {
when {
anyOf {
changeset comparator: 'REGEXP', pattern: "${updateTriggers}|(tests\\/.*)"
expression { return currentBuild.number == 1 }
triggeredBy 'UserIdCause'
}
}
steps {
sh 'mvn -B -T 1C clean install -P eclipse-sign'
}
}
stage('Test') {
when {
anyOf {
changeset comparator: 'REGEXP', pattern: "${baseTriggers}|(tests\\/.*)"
expression { return currentBuild.number == 1 }
triggeredBy 'UserIdCause'
}
}
steps {
wrap([$class: 'Xvnc', takeScreenshot: false, useXauthority: false]) {
sh 'mvn -B -f tests/org.eclipse.epsilon.test verify -P plugged'
}
sh 'mvn -B -f tests/org.eclipse.epsilon.test surefire:test -P ci'
}
}
stage('Javadocs') {
when {
anyOf {
changeset comparator: 'REGEXP', pattern: "${updateTriggers}"
expression { return currentBuild.number == 1 }
triggeredBy 'UserIdCause'
}
}
steps {
sh 'mvn -f plugins -B initialize javadoc:aggregate'
}
}
stage('Update site') {
when {
allOf {
branch 'main'
anyOf {
changeset comparator: 'REGEXP', pattern: "${updateTriggers}"
expression { return currentBuild.number == 1 }
triggeredBy 'UserIdCause'
}
}
}
steps {
sh 'mvn -f releng install -P updatesite'
lock('download-area') {
sshagent (['projects-storage.eclipse.org-bot-ssh']) {
sh '''
INTERIM=/home/data/httpd/download.eclipse.org/epsilon/interim
SITEDIR="$WORKSPACE/releng/org.eclipse.epsilon.updatesite/target"
if [ -d "$SITEDIR" ]; then
ssh [email protected] rm -rf $INTERIM
scp -r "$SITEDIR/repository" [email protected]:$INTERIM
scp "$SITEDIR"/*.zip [email protected]:$INTERIM/epsilon-interim-site.zip
fi
PROJECT_VERSION=$(grep Bundle-Version plugins/org.eclipse.epsilon.eol.engine/META-INF/MANIFEST.MF | awk '{print $2}' | tr -d '\r' | sed 's/.qualifier//')
JAVADOC=/home/data/httpd/download.eclipse.org/epsilon/interim-javadoc
JAVADOCDIR="$WORKSPACE/plugins/target/site/apidocs"
if [ -d "$JAVADOCDIR" ]; then
ssh [email protected] "rm -rf $JAVADOC"
scp -r "$JAVADOCDIR" [email protected]:$JAVADOC
if echo "$PROJECT_VERSION" | grep -Eq "^[0-9]+.[0-9]+.[0-9]+$"; then
echo "Uploading Javadocs for Epsilon ${PROJECT_VERSION}"
JAVADOC_VERSIONED=/home/data/httpd/download.eclipse.org/epsilon/${PROJECT_VERSION}-javadoc
ssh [email protected] "rm -rf $JAVADOC_VERSIONED"
scp -r "$JAVADOCDIR" [email protected]:$JAVADOC_VERSIONED
else
echo "Project version does not follow the expected X.Y.Z format: ${PROJECT_VERSION}"
exit 2
fi
else
echo "Could not find the Javadocs folder"
exit 1
fi
'''
}
}
}
}
stage('Plain Maven build') {
when {
anyOf {
changeset comparator: 'REGEXP', pattern: "${plainTriggers}"
expression { return currentBuild.number == 1 }
branch 'maven-*'
triggeredBy 'UserIdCause'
}
}
steps {
sh 'bash plugins/org.eclipse.epsilon.eunit.cmp.emf/download-emf-compare.sh'
sh 'mvn -B -T 1C -f pom-plain.xml compile'
}
}
stage('Deploy to OSSRH') {
when {
anyOf {
allOf {
branch 'main'
anyOf {
changeset comparator: 'REGEXP', pattern: "${plainTriggers}"
expression { return currentBuild.number == 1 }
triggeredBy 'UserIdCause'
}
}
branch 'maven-*'
}
}
environment {
KEYRING = credentials('secret-subkeys.asc')
}
steps {
sh '''
gpg --batch --import "${KEYRING}"
for fpr in $(gpg --list-keys --with-colons | awk -F: '/fpr:/ {print $10}' | sort -u);
do
echo -e "5\ny\n" | gpg --batch --command-fd 0 --expert --edit-key $fpr trust;
done
'''
lock('ossrh') {
sh 'mvn -B -f pom-plain.xml -P ossrh,eclipse-sign deploy'
}
}
}
}
}
}
post {
success {
slackSend (channel: '#ci-notifications', botUser: true, color: '#00FF00', message: getSlackMessage())
}
failure {
slackSend (channel: '#ci-notifications', botUser: true, color: '#FF0000', message: getSlackMessage())
script {
if (env.BRANCH_NAME == "main")
emailext(
to: '[email protected]',
subject: 'Epsilon Interim build failed!',
body: "${env.BUILD_TAG}. More info at ${env.BUILD_URL}",
charset: 'UTF-8',
mimeType: 'text/html'
)
}
}
}
}