forked from redhat-developer/vscode-xml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NativeImage.jenkins
140 lines (137 loc) · 6.67 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
// 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='-H:+StaticExecutableWithDynamicLibC' && cd .."
sh "rm lemminx/org.eclipse.lemminx/target/*.build_artifacts.txt"
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 }
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 """
git clone -b ${lemminxVersion} [email protected]:eclipse/lemminx.git
"""
} else {
powershell """
git clone [email protected]: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-java17-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-java17-${params.GRAALVM_VERSION}\\bin\\gu install native-image
}
"""
bat """
pushd .
setlocal
set JAVA_HOME=%cd%\\graalvm-windows-${params.GRAALVM_VERSION}\\graalvm-ce-java17-${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-java17-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-java17-${params.GRAALVM_VERSION}/Contents/Home/bin/gu install native-image
fi
"""
sh "cd lemminx && JAVA_HOME=`pwd`/../graalvm-ce-java17-${params.GRAALVM_VERSION}/Contents/Home ./mvnw clean package -B -Dnative -DskipTests && cd .."
sh "rm lemminx/org.eclipse.lemminx/target/*.build_artifacts.txt"
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"
stash name: 'checksums', includes: 'lemminx-*.sha256'
stash name: 'binaries', includes: 'lemminx-*.zip'
}
}
}
}