forked from eclipse-nattable/nattable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
130 lines (118 loc) · 5.51 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
pipeline {
agent {
kubernetes {
label 'migration'
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
}
tools {
maven 'apache-maven-latest'
jdk 'openjdk-jdk17-latest'
}
environment {
BUILD_DIR = "${WORKSPACE}/org.eclipse.nebula.widgets.nattable.examples.e4.product/target/products/"
DMG = "org.eclipse.nebula.widgets.nattable.examples.e4.product-macosx.cocoa.x86_64.dmg"
PRIMARY_BUNDLE_ID = "app-bundle"
SNAPSHOTS_DIR = "/home/data/httpd/download.eclipse.org/nattable/snapshots"
SNAPSHOT_BUILD_DIR = "${SNAPSHOTS_DIR}/${BUILD_NUMBER}"
SSH_HOST = "genie.nattable@projects-storage.eclipse.org"
}
stages {
stage('Build') {
steps {
wrap([$class: 'Xvnc', takeScreenshot: false, useXauthority: true]) {
sh 'mvn clean compile javadoc:aggregate verify -Psign -B'
}
}
}
stage('Notarize') {
when {
allOf {
not {
changeRequest()
}
anyOf { branch 'releases/*'; branch 'master' }
}
}
steps {
sh '''
echo "Notarize..."
pushd $BUILD_DIR
RESPONSE=\$(curl -s -X POST -F file=@${DMG} -F 'options={"primaryBundleId": "'${PRIMARY_BUNDLE_ID}'", "staple": true};type=application/json' https://cbi.eclipse.org/macos/xcrun/notarize)
UUID=\$(echo $RESPONSE | grep -Po '"uuid"\\s*:\\s*"\\K[^"]+')
STATUS=\$(echo $RESPONSE | grep -Po '"status"\\s*:\\s*"\\K[^"]+')
while [[ ${STATUS} == 'IN_PROGRESS' ]]; do
sleep 1m
RESPONSE=\$(curl -s https://cbi.eclipse.org/macos/xcrun/${UUID}/status)
STATUS=\$(echo $RESPONSE | grep -Po '"status"\\s*:\\s*"\\K[^"]+')
done
if [[ ${STATUS} != 'COMPLETE' ]]; then
echo "Notarization failed: ${RESPONSE}"
exit 1
fi
rm "${DMG}"
curl -JO https://cbi.eclipse.org/macos/xcrun/${UUID}/download
popd
'''
}
}
stage('Deploy') {
when {
allOf {
not {
changeRequest()
}
anyOf { branch 'releases/*'; branch 'master' }
}
}
steps {
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
sh '''
echo "Deploying..."
# Copy from Jenkins to download.eclipse.org
ssh ${SSH_HOST} mkdir -p ${SNAPSHOT_BUILD_DIR}/repository
scp -r ${WORKSPACE}/org.eclipse.nebula.widgets.nattable.updatesite/target/repository/* ${SSH_HOST}:${SNAPSHOT_BUILD_DIR}/repository
scp ${WORKSPACE}/org.eclipse.nebula.widgets.nattable.examples/target/*.jar ${SSH_HOST}:${SNAPSHOT_BUILD_DIR}
scp ${WORKSPACE}/org.eclipse.nebula.widgets.nattable.examples.e4.product/target/products/*.zip ${SSH_HOST}:${SNAPSHOT_BUILD_DIR}
scp ${WORKSPACE}/org.eclipse.nebula.widgets.nattable.examples.e4.product/target/products/*.tar.gz ${SSH_HOST}:${SNAPSHOT_BUILD_DIR}
scp ${WORKSPACE}/org.eclipse.nebula.widgets.nattable.examples.e4.product/target/products/*.dmg ${SSH_HOST}:${SNAPSHOT_BUILD_DIR}
scp -r ${WORKSPACE}/target/site/apidocs ${SSH_HOST}:${SNAPSHOT_BUILD_DIR}
# ssh on download.eclipse.org
ssh ${SSH_HOST} << EOF
# create the .metadata file
echo ${BUILD_ID} > ${SNAPSHOT_BUILD_DIR}/.metadata
# Zip
cd ${SNAPSHOT_BUILD_DIR}/repository
zip -r ../repository.zip *
# Delete old latest snapshot
rm -rf ${SNAPSHOTS_DIR}/latest
# Delete old snapshot directories; only keep latest 5
ls -dt ${SNAPSHOTS_DIR}/*/ | tail -n +7 | xargs rm -rf
# Copy latest snapshot build to latest snapshot repository
cp -r ${SNAPSHOT_BUILD_DIR} ${SNAPSHOTS_DIR}/latest
# Copy latest snapshot build to release (only enabled for release build)
# cp -r ${SNAPSHOT_BUILD_DIR} /home/data/httpd/download.eclipse.org/nattable/releases/2.0.0
<< EOF
'''
}
}
}
}
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: 'nattable-dev@eclipse.org'
}
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: 'nattable-dev@eclipse.org'
}
}
}