Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 74 additions & 31 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,73 @@
#!/usr/bin/env groovy

def installBuildRequirements(){
def nodeHome = tool 'nodejs-12.13.1'
def nodeHome = tool 'nodejs-14.19.1'
env.PATH="${env.PATH}:${nodeHome}/bin"
sh "npm install -g typescript"
sh 'npm install -g "vsce@<2"'
sh 'npm install -g "vsce"'
}

def buildVscodeExtension(){
sh "npm install"
sh "npm run vscode:prepublish"
}

def packageGenericExtension() {
stage "Package vscode-java"
def packageJson = readJSON file: 'package.json'
env.EXTENSION_VERSION = "${packageJson.version}"

if (publishPreRelease.equals('true')) {
sh "vsce package --pre-release -o java-${env.EXTENSION_VERSION}-${env.BUILD_NUMBER}.vsix"
} else {
sh "vsce package -o java-${env.EXTENSION_VERSION}-${env.BUILD_NUMBER}.vsix"
}

stage 'Test vscode-java for staging'
wrap([$class: 'Xvnc']) {
sh "npm run compile" //compile the test code too
env.SKIP_COMMANDS_TEST="true"
sh "npm test --silent"
}
}

def packageSpecificExtensions() {
stage "Package platform specific vscode-java"
def platforms = ["win32-x64", "linux-x64", "linux-arm64", "darwin-x64", "darwin-arm64"]
def embeddedJRE = 17
for(platform in platforms){
sh "npx gulp download_jre --target ${platform} --javaVersion ${embeddedJRE}"
if (publishPreRelease.equals('true')) {
sh "vsce package --pre-release --target ${platform} -o java-${platform}-${env.EXTENSION_VERSION}-${env.BUILD_NUMBER}.vsix"
} else {
sh "vsce package --target ${platform} -o java-${platform}-${env.EXTENSION_VERSION}-${env.BUILD_NUMBER}.vsix"
}
}
}

def publishPreReleaseExtensions() {
stage "replace extension version"
sh "node ./scripts/prepare-nightly-build.js"
sh "mv ./package.insiders.json ./package.json"
packageGenericExtension()
def vsix = findFiles(glob: '**.vsix')

stage "publish generic version"
withCredentials([[$class: 'StringBinding', credentialsId: 'vscode_java_marketplace', variable: 'TOKEN']]) {
sh 'vsce publish -p ${TOKEN} --target win32-ia32 win32-arm64 linux-armhf alpine-x64 alpine-arm64'
}

stage "publish specific version"
packageSpecificExtensions()
withCredentials([[$class: 'StringBinding', credentialsId: 'vscode_java_marketplace', variable: 'TOKEN']]) {
sh 'npx gulp clean_jre'
def platformVsixes = findFiles(glob: '**.vsix', excludes: vsix[0].path)
for(platformVsix in platformVsixes){
sh 'vsce publish -p ${TOKEN}' + " --packagePath ${platformVsix.path}"
}
}
}

node('rhel8'){
stage 'Build JDT LS'

Expand Down Expand Up @@ -44,39 +100,26 @@ node('rhel8'){
sh "mkdir ./server"
sh "tar -xvzf ${files[0].path} -C ./server"

stage "Package vscode-java"
def packageJson = readJSON file: 'package.json'
env.EXTENSION_VERSION = "${packageJson.version}"
sh "vsce package -o java-${env.EXTENSION_VERSION}-${env.BUILD_NUMBER}.vsix"
if (publishPreRelease.equals('true')) {
publishPreReleaseExtensions()
} else {
packageGenericExtension()
def vsix = findFiles(glob: '**.vsix')
stash name:'vsix', includes:vsix[0].path

stage 'Test vscode-java for staging'
wrap([$class: 'Xvnc']) {
sh "npm run compile" //compile the test code too
env.SKIP_COMMANDS_TEST="true"
sh "npm test --silent"
}
// Package platform specific versions
packageSpecificExtensions()
stash name:'platformVsix', includes:'java-win32-*.vsix,java-linux-*.vsix,java-darwin-*.vsix'

def vsix = findFiles(glob: '**.vsix')
stash name:'vsix', includes:vsix[0].path
stage 'Upload vscode-java to staging'
def artifactDir = "java-${env.EXTENSION_VERSION}-${env.BUILD_NUMBER}"
sh "mkdir ${artifactDir}"
sh "mv *.vsix ${artifactDir}"

// Package platform specific versions
stage "Package platform specific vscode-java"
def platforms = ["win32-x64", "linux-x64", "linux-arm64", "darwin-x64", "darwin-arm64"]
def embeddedJRE = 17
for(platform in platforms){
sh "npx gulp download_jre --target ${platform} --javaVersion ${embeddedJRE}"
sh "vsce package --target ${platform} -o java-${platform}-${env.EXTENSION_VERSION}-${env.BUILD_NUMBER}.vsix"
sh "sftp ${UPLOAD_LOCATION}/jdt.ls/staging <<< \$'mkdir ${artifactDir}\nput -r ${artifactDir}'"
// Clean up build vsix
sh "rm -rf ${artifactDir}"
}
stash name:'platformVsix', includes:'java-win32-*.vsix,java-linux-*.vsix,java-darwin-*.vsix'

stage 'Upload vscode-java to staging'
def artifactDir = "java-${env.EXTENSION_VERSION}-${env.BUILD_NUMBER}"
sh "mkdir ${artifactDir}"
sh "mv *.vsix ${artifactDir}"

sh "sftp ${UPLOAD_LOCATION}/jdt.ls/staging <<< \$'mkdir ${artifactDir}\nput -r ${artifactDir}'"
// Clean up build vsix
sh "rm -rf ${artifactDir}"
}

node('rhel8'){
Expand Down
25 changes: 25 additions & 0 deletions scripts/prepare-nightly-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const fs = require("fs");

const json = JSON.parse(fs.readFileSync("./package.json").toString());
const stableVersion = json.version.match(/(\d+)\.(\d+)\.(\d+)/);
const major = stableVersion[1];
const minor = stableVersion[2];

function prependZero(number) {
if (number > 99) {
throw "Unexpected value to prepend with zero";
}
return `${number < 10 ? "0" : ""}${number}`;
}

const date = new Date();
const month = date.getMonth() + 1;
const day = date.getDate();
const hours = date.getHours();
patch = `${date.getFullYear()}${prependZero(month)}${prependZero(day)}${prependZero(hours)}`;

const insiderPackageJson = Object.assign(json, {
version: `${major}.${minor}.${patch}`,
});

fs.writeFileSync("./package.insiders.json", JSON.stringify(insiderPackageJson, null, 2));