Skip to content

Commit 7cf3c86

Browse files
committed
Support pre-releases and platform-specific extensions on OpenVSX
- Refactor the Jenkinsfile for simplicity - There should only be 2 calls to vsce/ovsx . One call to publish the generic version, and another to package the platform-specific versions (in a for-loop) - The logic to publish pre-release versions should be done transparently - When publishing a pre-release, all package specific vsixs should embed that data at package-time Signed-off-by: Roland Grunberg <[email protected]>
1 parent 1d8c85d commit 7cf3c86

File tree

1 file changed

+37
-49
lines changed

1 file changed

+37
-49
lines changed

Jenkinsfile

Lines changed: 37 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ def installBuildRequirements(){
55
env.PATH="${env.PATH}:${nodeHome}/bin"
66
sh "npm install -g typescript"
77
sh 'npm install -g "vsce"'
8+
sh 'npm install -g "ovsx"'
89
}
910

1011
def buildVscodeExtension(){
@@ -23,33 +24,27 @@ def packageSpecificExtensions() {
2324
def embeddedJRE = 17
2425
for(platform in platforms){
2526
sh "npx gulp download_jre --target ${platform} --javaVersion ${embeddedJRE}"
26-
if (publishPreRelease.equals('true')) {
27-
sh "vsce package --pre-release --target ${platform} -o java-${platform}-${env.EXTENSION_VERSION}-${env.BUILD_NUMBER}.vsix"
28-
} else {
29-
sh "vsce package --target ${platform} -o java-${platform}-${env.EXTENSION_VERSION}-${env.BUILD_NUMBER}.vsix"
30-
}
27+
sh "vsce package ${env.publishPreReleaseFlag} --target ${platform} -o java-${platform}-${env.EXTENSION_VERSION}-${env.BUILD_NUMBER}.vsix"
3128
}
3229
}
3330

3431
def packageExtensions() {
32+
env.publishPreReleaseFlag = ""
3533
if (publishPreRelease.equals('true')) {
36-
// for pre-release versions we only package platform specific extensions
3734
stage "replace extension version"
3835
sh "npx gulp prepare_pre_release"
3936

4037
def packageJson = readJSON file: 'package.json'
4138
env.EXTENSION_VERSION = "${packageJson.version}"
39+
env.publishPreReleaseFlag = "--pre-release"
4240

4341
packageSpecificExtensions()
4442
} else {
4543
stage "package generic version"
4644
def packageJson = readJSON file: 'package.json'
4745
env.EXTENSION_VERSION = "${packageJson.version}"
4846

49-
sh "vsce package -o java-${env.EXTENSION_VERSION}-${env.BUILD_NUMBER}.vsix"
50-
51-
def vsix = findFiles(glob: '**.vsix')
52-
stash name:'vsix', includes:vsix[0].path
47+
sh "vsce package ${env.publishPreReleaseFlag} -o java-${env.EXTENSION_VERSION}-${env.BUILD_NUMBER}.vsix"
5348

5449
packageSpecificExtensions()
5550
stash name:'platformVsix', includes:'java-win32-*.vsix,java-linux-*.vsix,java-darwin-*.vsix'
@@ -62,57 +57,48 @@ def packageExtensions() {
6257
sh "sftp ${UPLOAD_LOCATION}/jdt.ls/staging <<< \$'mkdir ${artifactDir}\nput -r ${artifactDir}'"
6358
// Clean up build vsix
6459
sh "rm -rf ${artifactDir}"
60+
unstash 'platformVsix'
6561
}
6662
}
6763

6864
def publishExtensions() {
69-
if (publishPreRelease.equals('true')) {
70-
stage "publish generic version"
71-
withCredentials([[$class: 'StringBinding', credentialsId: 'vscode_java_marketplace', variable: 'TOKEN']]) {
72-
// Clean up embedded jre folder from previous build
73-
sh 'npx gulp clean_jre'
74-
// Publish a generic version
75-
sh 'vsce publish --pre-release -p ${TOKEN} --target win32-ia32 win32-arm64 linux-armhf alpine-x64 alpine-arm64'
76-
}
65+
// Clean up embedded jre folder from previous build
66+
sh 'npx gulp clean_jre'
7767

78-
stage "publish specific version"
79-
// for pre-release versions, vsixs are not stashed and kept in project folder
80-
withCredentials([[$class: 'StringBinding', credentialsId: 'vscode_java_marketplace', variable: 'TOKEN']]) {
81-
def platformVsixes = findFiles(glob: '**.vsix')
82-
for(platformVsix in platformVsixes){
83-
sh 'vsce publish -p ${TOKEN}' + " --packagePath ${platformVsix.path}"
84-
}
85-
}
86-
} else if (publishToMarketPlace.equals('true')) {
68+
if (publishToMarketPlace.equals('true') || publishToOVSX.equals('true')) {
8769
timeout(time:5, unit:'DAYS') {
8870
input message:'Approve deployment?', submitter: 'fbricon,rgrunber'
8971
}
72+
}
9073

91-
stage "Publish to Open-vsx Marketplace"
92-
unstash 'vsix'
93-
def vsix = findFiles(glob: '**.vsix')
94-
// Open-vsx Marketplace
95-
sh 'npm install -g "ovsx"'
96-
withCredentials([[$class: 'StringBinding', credentialsId: 'open-vsx-access-token', variable: 'OVSX_TOKEN']]) {
97-
sh 'ovsx publish -p ${OVSX_TOKEN}' + " ${vsix[0].path}"
74+
def platformVsixes = findFiles(glob: '**.vsix')
75+
76+
stage "publish generic version to VS Code Marketplace"
77+
withCredentials([[$class: 'StringBinding', credentialsId: 'vscode_java_marketplace', variable: 'TOKEN']]) {
78+
sh 'vsce publish -p ${TOKEN} --target win32-ia32 win32-arm64 linux-armhf alpine-x64 alpine-arm64' + " ${env.publishPreReleaseFlag}"
79+
}
80+
81+
stage "publish specific version to VS Code Marketplace"
82+
83+
withCredentials([[$class: 'StringBinding', credentialsId: 'vscode_java_marketplace', variable: 'TOKEN']]) {
84+
for(platformVsix in platformVsixes){
85+
sh 'vsce publish -p ${TOKEN}' + " --packagePath ${platformVsix.path}"
9886
}
87+
}
9988

100-
stage "Publish to VS Code Marketplace"
101-
// VS Code Marketplace
102-
withCredentials([[$class: 'StringBinding', credentialsId: 'vscode_java_marketplace', variable: 'TOKEN']]) {
103-
// Clean up embedded jre folder from previous build
104-
sh 'npx gulp clean_jre'
105-
// Publish a generic version
106-
sh 'vsce publish -p ${TOKEN} --target win32-ia32 win32-arm64 linux-armhf alpine-x64 alpine-arm64'
107-
108-
// Publish platform specific versions
109-
unstash 'platformVsix'
110-
def platformVsixes = findFiles(glob: '**.vsix', excludes: vsix[0].path)
111-
for(platformVsix in platformVsixes){
112-
sh 'vsce publish -p ${TOKEN}' + " --packagePath ${platformVsix.path}"
113-
}
89+
stage "Publish generic version to Open-VSX Marketplace"
90+
withCredentials([[$class: 'StringBinding', credentialsId: 'open-vsx-access-token', variable: 'OVSX_TOKEN']]) {
91+
sh 'ovsx publish -p ${OVSX_TOKEN} --target win32-ia32 win32-arm64 linux-armhf alpine-x64 alpine-arm64' + " ${env.publishPreReleaseFlag}"
92+
}
93+
94+
stage "Publish specific version to Open-VSX Marketplace"
95+
withCredentials([[$class: 'StringBinding', credentialsId: 'open-vsx-access-token', variable: 'OVSX_TOKEN']]) {
96+
for(platformVsix in platformVsixes){
97+
sh 'ovsx publish -p ${OVSX_TOKEN}' + " --packagePath ${platformVsix.path}"
11498
}
99+
}
115100

101+
if (publishToMarketPlace.equals('true') || publishToOVSX.equals('true')) {
116102
stage "Publish to http://download.jboss.org/jbosstools/static/jdt.ls/stable/"
117103
def artifactDir = "java-${env.EXTENSION_VERSION}"
118104
sh "mkdir ${artifactDir}"
@@ -168,5 +154,7 @@ node('rhel8'){
168154

169155
packageExtensions()
170156

171-
publishExtensions()
157+
if (publishPreRelease.equals('true') || publishToMarketPlace.equals('true') || publishToOVSX.equals('true')) {
158+
publishExtensions()
159+
}
172160
}

0 commit comments

Comments
 (0)