-
Notifications
You must be signed in to change notification settings - Fork 75
/
Jenkinsfile
120 lines (102 loc) · 4.2 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
#!/usr/bin/env groovy
def installBuildRequirements(){
def nodeHome = tool 'nodejs-12.13.1'
env.PATH="${env.PATH}:${nodeHome}/bin"
sh "npm install -g typescript"
sh 'npm install -g "vsce@<2"'
}
def buildVscodeExtension(){
sh "npm install"
sh "npm run vscode:prepublish"
}
def buildLemMinXBinary() {
sh "curl -Lo NativeImage.jenkins https://raw.githubusercontent.com/${params.FORK}/vscode-xml/${params.BRANCH}/NativeImage.jenkins"
load "NativeImage.jenkins"
}
node('rhel8'){
sh "curl -Lo package.json https://raw.githubusercontent.com/${params.FORK}/vscode-xml/${params.BRANCH}/package.json"
def packageJson = readJSON file: 'package.json'
def serverVersion = packageJson?.xmlServer?.version
def files = []
if (serverVersion && publishToMarketPlace.equals('true')) {
stage 'Download XML LS'
def serverUrl = "https://repo.eclipse.org/content/repositories/lemminx-releases/org/eclipse/lemminx/org.eclipse.lemminx/${serverVersion}/org.eclipse.lemminx-${serverVersion}-uber.jar"
sh "curl -Lo org.eclipse.lemminx-${serverVersion}-uber.jar ${serverUrl}"
files = findFiles(glob: 'org.eclipse.lemminx*-uber.jar')
}
buildLemMinXBinary()
if (!files[0]) {
stage 'Build XML LS'
git url: 'https://github.com/eclipse/lemminx.git'
sh "./mvnw clean verify -B -U -e -P!jboss-maven-repos,!redhat-ga-repository,!redhat-ea-repository"
sh "mv org.eclipse.lemminx/target/org.eclipse.lemminx*-uber.jar ."
files = findFiles(glob: 'org.eclipse.lemminx*-uber.jar')
}
stash name: 'server_distro', includes :files[0].path
}
node('rhel8'){
stage 'Checkout vscode-xml code'
deleteDir()
def gitUrl = "${GIT_REPO}"
git url: gitUrl?:'https://github.com/redhat-developer/vscode-xml.git', branch: params.BRANCH?: 'master'
stage 'set the link to download the binary server'
def packageJson = readJSON file: 'package.json'
def binaryUploadFolder = 'latest'
def downloadLocation = 'https://github.com/redhat-developer/vscode-xml'
if (publishToMarketPlace.equals('true')) {
sh "sed -i -e 's|${downloadLocation}/releases/download/latest|${downloadLocation}/releases/download/${packageJson.version}|g' package.json"
}
stage 'install vscode-xml build requirements'
installBuildRequirements()
stage 'Build vscode-xml'
buildVscodeExtension()
unstash 'server_distro'
def files = findFiles(glob: '**/org.eclipse.lemminx*-uber.jar')
sh "mkdir ./server"
sh "mv ${files[0].path} ./server"
stage "Package vscode-xml"
sh "mkdir ../staging"
unstash 'binaries'
unstash 'checksums'
sh "mv lemminx-* ../staging"
def platformToTarget = [ "linux" : "linux-x64", "win32" : "win32-x64", "osx-x86_64" : "darwin-x64" ]
for(entry in platformToTarget){
def platform = entry.key
def target = entry.value
sh "unzip -d ./server ../staging/lemminx-${platform}.zip"
sh "cp ../staging/lemminx-${platform}.sha256 ./server"
sh "vsce package --target ${target} -o vscode-xml-${target}-${packageJson.version}-${env.BUILD_NUMBER}.vsix"
sh "rm ./server/lemminx-*"
}
sh "vsce package -o vscode-xml-${packageJson.version}-${env.BUILD_NUMBER}.vsix"
//stage 'Test vscode-xml for staging'
//wrap([$class: 'Xvnc']) {
// sh "npm test --silent"
//}
stage 'Archive artifacts'
archiveArtifacts artifacts: '*.vsix'
stash name:'vsix', includes:'*.vsix'
}
node('rhel8'){
if(publishToMarketPlace.equals('true')){
timeout(time:2, unit:'DAYS') {
input message:'Approve deployment?', submitter: 'fbricon,rgrunber,azerr,davthomp'
}
stage "Publish to Marketplaces"
unstash 'vsix'
def vsix = findFiles(glob: '**.vsix')
// VS Code Marketplace
withCredentials([[$class: 'StringBinding', credentialsId: 'vscode_java_marketplace', variable: 'TOKEN']]) {
def platformVsixes = findFiles(glob: '**.vsix', excludes: vsix[0].path)
for(platformVsix in platformVsixes){
sh 'vsce publish -p ${TOKEN}' + " --packagePath ${platformVsix.path}"
}
sh 'vsce publish -p ${TOKEN} --target win32-ia32 win32-arm64 linux-arm64 linux-armhf alpine-x64 alpine-arm64 darwin-arm64 --packagePath' + " ${vsix[0].path}"
}
// Open-vsx Marketplace
sh 'npm install -g "ovsx@<0.3.0"'
withCredentials([[$class: 'StringBinding', credentialsId: 'open-vsx-access-token', variable: 'OVSX_TOKEN']]) {
sh 'ovsx publish -p ${OVSX_TOKEN}' + " ${vsix[0].path}"
}
}// if publishToMarketPlace
}