forked from eclipse-lyo/lyo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
166 lines (163 loc) · 5.88 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
pipeline {
agent any
options {
timeout(time: 40, unit: 'MINUTES') // timeout on whole pipeline job
disableConcurrentBuilds(abortPrevious: false)
}
tools {
maven 'apache-maven-latest'
jdk 'temurin-jdk17-latest'
}
triggers {
pollSCM('H/10 * * * *')
}
stages {
stage('SonarCloud') {
when {
allOf {
// triggeredBy 'SCMTrigger'
not {
environment name: 'CHANGE_AUTHOR', value: 'dependabot[bot]'
}
not {
environment name: 'CHANGE_AUTHOR', value: 'dependabot-preview[bot]'
}
not {
branch pattern: 'dependabot/*', comparator: 'REGEXP'
}
}
}
environment {
PROJECT_NAME = 'lyo'
}
steps {
withCredentials([string(credentialsId: 'sonarcloud-token', variable: 'SONARCLOUD_TOKEN')]) {
withSonarQubeEnv('SonarCloud.io') {
script {
def sonar_pr = ''
if (env.CHANGE_ID) {
sonar_pr += " -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=eclipse/${env.PROJECT_NAME} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH}"
}
sh '''
mvn clean verify -B org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
-Dsonar.projectKey=org.eclipse.lyo -Dsonar.organization=eclipse -Dsonar.host.url=${SONAR_HOST_URL} -Dsonar.token=${SONARCLOUD_TOKEN}''' + sonar_pr
}
}
}
}
}
stage('Publish (OSSRH)') {
when {
anyOf {
branch 'master'
branch 'main'
branch 'maint-*'
}
}
steps {
withCredentials([file(credentialsId: 'secret-subkeys.asc', variable: 'KEYRING')]) {
sh 'gpg --batch --import "${KEYRING}"'
sh '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'
}
sh '''
mvn -B -fae clean install -DskipTests javadoc:aggregate \
-P dev,gpg-sign,!eclipse-deploy,ossrh-deploy
mvn -B deploy -DskipTests -Dmaven.install.skip=true \
-P dev,gpg-sign,!eclipse-deploy,ossrh-deploy
'''
}
}
stage('Publish (Javadocs)') {
when {
anyOf {
branch 'master'
branch 'main'
branch 'maint-*'
}
}
steps {
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
sh '''
DOCS_HOME=/home/data/httpd/download.eclipse.org/lyo/docs/all
VERSION=$(mvn -q \
-Dexec.executable="echo" \
-Dexec.args='${project.version}' \
--non-recursive \
org.codehaus.mojo:exec-maven-plugin:1.3.1:exec | tail -n 1 | xargs)
# see https://github.com/eclipse/lyo.core/issues/135 for the tail/xargs temp fix
ssh [email protected] rm -rf $DOCS_HOME/$VERSION
ssh [email protected] mkdir -p $DOCS_HOME/$VERSION
scp -rp target/site/apidocs/ [email protected]:$DOCS_HOME/$VERSION
'''
}
}
}
stage('Publish (Eclipse)') {
when {
anyOf {
branch 'master'
branch 'main'
branch 'maint-*'
}
}
steps {
sh '''
mvn -B deploy -DskipTests -Dmaven.install.skip=true \
-P dev,gpg-sign,eclipse-deploy
'''
// sh 'gpg --verify my-app/target/my-app-1.0-SNAPSHOT.jar.asc'
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
sh '''
DOCS_HOME=/home/data/httpd/download.eclipse.org/lyo/docs/all
VERSION=$(mvn -q \
-Dexec.executable="echo" \
-Dexec.args='${project.version}' \
--non-recursive \
org.codehaus.mojo:exec-maven-plugin:1.3.1:exec | tail -n 1 | xargs)
# see https://github.com/eclipse/lyo.core/issues/135 for the tail/xargs temp fix
ssh [email protected] rm -rf $DOCS_HOME/$VERSION
ssh [email protected] mkdir -p $DOCS_HOME/$VERSION
scp -rp target/site/apidocs/ [email protected]:$DOCS_HOME/$VERSION
'''
}
}
}
stage('Publish HEAD Javadocs') {
when {
triggeredBy 'SCMTrigger'
branch 'master'
}
steps {
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
sh '''
DOCS_HOME=/home/data/httpd/download.eclipse.org/lyo/docs/all
VERSION=$(mvn -q \
-Dexec.executable="echo" \
-Dexec.args='${project.version}' \
--non-recursive \
org.codehaus.mojo:exec-maven-plugin:1.3.1:exec | tail -n 1 | xargs)
# see https://github.com/eclipse/lyo.core/issues/135 for the tail/xargs temp fix
ssh [email protected] rm -rf $DOCS_HOME/latest
ssh [email protected] mkdir -p $DOCS_HOME/latest
scp -rp target/site/apidocs/ [email protected]:$DOCS_HOME/latest
'''
}
}
}
}
post {
// send a mail on unsuccessful and fixed builds
unsuccessful { // means unstable || failure || aborted
emailext subject: 'Build $BUILD_STATUS $PROJECT_NAME #$BUILD_NUMBER!',
body: '''Check console output at $BUILD_URL to view the results.''',
recipientProviders: [culprits(), requestor()],
to: '[email protected]'
}
fixed { // back to normal
emailext subject: 'Build $BUILD_STATUS $PROJECT_NAME #$BUILD_NUMBER!',
body: '''Check console output at $BUILD_URL to view the results.''',
recipientProviders: [culprits(), requestor()],
to: '[email protected]'
}
}
}