forked from redhat-developer/vscode-xml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NativeImage.jenkins
168 lines (164 loc) · 8.32 KB
/
NativeImage.jenkins
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
// Parameters that need to be declared for this pipeline:
// * GRAALVM_VERSION: The version of GraalVM to download in the Windows an macOS builds
// * publishToMarketPlace: Upload to the "stable" folder if true, upload to the "snapshots" folder if false
// * UPLOAD_LOCATION: The base location where the artifacts (binaries and sha256 hashes) will be uploaded
// * FORK: The fork of vscode-xml that is being built for
// * BRANCH: The branch of vscode-xml that is being built for
pipeline {
agent none
stages {
stage("native-image") {
parallel {
// Assumes GraalVM is set up on the rhel8 agent, and the environment variable "GRAALVM_PATH" points to its location
stage("Linux native-image") {
agent {
label "rhel8"
}
steps {
sh "rm -f lemminx-linux"
sh "rm -rf lemminx"
script {
if (publishToMarketPlace.equals('true')) {
sh "curl -Lo package.json https://raw.githubusercontent.com/${params.FORK}/vscode-xml/${params.BRANCH}/package.json"
def packageJson = readJSON file: 'package.json'
def lemminxVersion = packageJson?.xmlServer?.version
sh "git clone -b ${lemminxVersion} https://github.com/eclipse/lemminx.git"
} else {
sh "git clone https://github.com/eclipse/lemminx.git"
}
}
sh "cd lemminx && JAVA_HOME=\$GRAALVM_PATH ./mvnw clean package -B -Dnative -DskipTests -Dgraalvm.static='--static -H:+StaticExecutableWithDynamicLibC' && cd .."
sh "cp lemminx/org.eclipse.lemminx/target/lemminx-linux* lemminx-linux"
stash name: 'lemminx-linux', includes: 'lemminx-linux'
}
}
stage("Windows native-image") {
agent {
label "win10"
}
steps {
powershell "if (Test-Path lemminx-win32.exe) { Remove-Item lemminx-win32.exe }"
powershell "Remove-Item -Recurse -Force lemminx"
script {
if (publishToMarketPlace.equals('true')) {
powershell """
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest https://raw.githubusercontent.com/${params.FORK}/vscode-xml/${params.BRANCH}/package.json -OutFile package.json
"""
def packageJson = readJSON file: 'package.json'
def lemminxVersion = packageJson?.xmlServer?.version
powershell """
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
git clone -b ${lemminxVersion} https://github.com/eclipse/lemminx.git
"""
} else {
powershell """
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
git clone https://github.com/eclipse/lemminx.git
"""
}
}
powershell """
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if (-not (Test-Path graalvm-windows-${params.GRAALVM_VERSION}.zip)) {
Invoke-WebRequest https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${params.GRAALVM_VERSION}/graalvm-ce-java11-windows-amd64-${params.GRAALVM_VERSION}.zip -OutFile graalvm-windows-${params.GRAALVM_VERSION}.zip
Expand-Archive graalvm-windows-${params.GRAALVM_VERSION}.zip
.\\graalvm-windows-${params.GRAALVM_VERSION}\\graalvm-ce-java11-${params.GRAALVM_VERSION}\\bin\\gu install native-image
}
"""
bat """
pushd .
setlocal
set JAVA_HOME=%cd%\\graalvm-windows-${params.GRAALVM_VERSION}\\graalvm-ce-java11-${params.GRAALVM_VERSION}
call \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat\"
popd
cd lemminx
.\\mvnw.cmd clean package -B -Dnative -DskipTests
endlocal
cd ..
"""
powershell "mv lemminx\\org.eclipse.lemminx\\target\\lemminx-windows*.exe lemminx-win32.exe"
stash name: 'lemminx-win32.exe', includes: 'lemminx-win32.exe'
}
}
stage("macOS native-image") {
agent {
label "mac"
}
steps {
sh "rm -f lemminx-osx-x86_64.zip lemminx-osx-x86_64.sha256"
sh "rm -rf lemminx"
script {
if (publishToMarketPlace.equals('true')) {
sh "curl -Lo package.json https://raw.githubusercontent.com/${params.FORK}/vscode-xml/${params.BRANCH}/package.json"
def packageJson = readJSON file: 'package.json'
def lemminxVersion = packageJson?.xmlServer?.version
sh "git clone -b ${lemminxVersion} https://github.com/eclipse/lemminx.git"
} else {
sh "git clone https://github.com/eclipse/lemminx.git"
}
}
sh """
if [ ! -f graalvm-darwin-${params.GRAALVM_VERSION}.tar.gz ]; then
curl https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${params.GRAALVM_VERSION}/graalvm-ce-java8-darwin-amd64-${params.GRAALVM_VERSION}.tar.gz -L --output graalvm-darwin-${params.GRAALVM_VERSION}.tar.gz
tar -xzf graalvm-darwin-${params.GRAALVM_VERSION}.tar.gz
./graalvm-ce-java8-${params.GRAALVM_VERSION}/Contents/Home/bin/gu install native-image
fi
"""
sh "cd lemminx && JAVA_HOME=../graalvm-ce-java8-${params.GRAALVM_VERSION}/Contents/Home ./mvnw clean package -B -Dnative -DskipTests && cd .."
sh "cp lemminx/org.eclipse.lemminx/target/lemminx-osx-x86_64* lemminx-osx-x86_64"
stash name: 'lemminx-osx-x86_64', includes: 'lemminx-osx-x86_64'
}
}
}
}
stage ("Zip and upload") {
agent {
label "rhel8"
}
steps {
unstash name: 'lemminx-linux'
unstash name: 'lemminx-win32.exe'
unstash name: 'lemminx-osx-x86_64'
sh "zip lemminx-linux.zip lemminx-linux"
sh "zip lemminx-win32.zip lemminx-win32.exe"
sh "zip lemminx-osx-x86_64.zip lemminx-osx-x86_64"
// get the sha256 hash of the binaries
sh "sha256sum lemminx-linux > lemminx-linux.sha256"
sh "sha256sum lemminx-win32.exe > lemminx-win32.sha256"
sh "sha256sum lemminx-osx-x86_64 > lemminx-osx-x86_64.sha256"
// Move artifacts into a folder name unique to this build
sh "curl -Lo package.json https://raw.githubusercontent.com/${params.FORK}/vscode-xml/${params.BRANCH}/package.json"
script {
def packageJson = readJSON file: 'package.json'
def vscodeXmlVersion = packageJson?.version
def uploadFolderName = 'snapshots'
if (publishToMarketPlace.equals('true')) {
uploadFolderName = 'stable'
}
sh "mkdir ${vscodeXmlVersion}-${env.BUILD_NUMBER}"
sh """
cp lemminx-linux.zip ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-linux.zip
cp lemminx-linux.sha256 ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-linux.sha256
cp lemminx-win32.zip ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-win32.zip
cp lemminx-win32.sha256 ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-win32.sha256
cp lemminx-osx-x86_64.zip ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-osx-x86_64.zip
cp lemminx-osx-x86_64.sha256 ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-osx-x86_64.sha256
"""
if (!publishToMarketPlace.equals('true')){
sh """
ln --symbolic ${vscodeXmlVersion}-${env.BUILD_NUMBER} LATEST
rsync -Pzrlt --rsh=ssh --protocol=28 LATEST ${params.UPLOAD_LOCATION}/vscode/snapshots/lemminx-binary
"""
}
// Upload the uniquely named folder to JBossTools
sh """
rsync -Pzrlt --rsh=ssh --protocol=28 ${vscodeXmlVersion}-${env.BUILD_NUMBER} ${params.UPLOAD_LOCATION}/vscode/${uploadFolderName}/lemminx-binary
rm -rf ${vscodeXmlVersion}-${env.BUILD_NUMBER}
rm -f LATEST
"""
}
}
}
}
}