forked from eclipse-lyo/lyo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
107 lines (105 loc) · 3.82 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
pipeline {
agent any
options {
timeout(time: 40, unit: 'MINUTES') // timeout on whole pipeline job
}
tools {
maven 'apache-maven-latest'
jdk 'temurin-jdk11-latest'
}
stages {
stage('SonarCloud') {
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.login=${SONARCLOUD_TOKEN}''' + sonar_pr
}
}
}
}
}
stage('Deploy') {
when {
anyOf {
branch 'master'
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
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 latest Javadocs') {
when {
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]'
}
}
}