Browse Source

Automate release for other supported branches

INT-2315
Seb 5 years ago
parent
commit
d376844d5b
  1. 26
      Jenkinsfile

26
Jenkinsfile

@ -3,6 +3,24 @@
standardProperties() standardProperties()
def isSupportedBranch() {
def branchName = env.BRANCH_NAME ? env.BRANCH_NAME : env.GIT_BRANCH
return branchName == 'v3.x' || branchName == 'origin/v3.x';
}
def isNewerTaggedVersion(tagName) {
def packageName = sh(script: 'node -p -e "require(\'./package.json\').name"', returnStdout: true).trim()
if (packageName && tagName) {
def remoteVersion = sh(script: "npm view ${packageName}@${tagName} version", returnStdout: true)
echo "Validating remote version: " + remoteVersion
def localVersion = sh(script: 'node -p -e "require(\'./package.json\').version"', returnStdout: true)
if (localVersion) {
return isNewerVersion(remoteVersion, localVersion)
}
}
return false
}
node("primary") { node("primary") {
echo "Clean workspace" echo "Clean workspace"
cleanWs() cleanWs()
@ -56,9 +74,13 @@ node("primary") {
} }
} }
if (isReleaseBranch() && isPackageNewerVersion()) {
stage("Publish") {
stage("Publish") {
if (isReleaseBranch() && isPackageNewerVersion()) {
sh 'npm publish' sh 'npm publish'
} else if (isSupportedBranch() && isNewerTaggedVersion('vue2')) {
sh 'npm publish --tag vue2'
} else {
echo "Nothing to publish"
} }
} }
} }
Loading…
Cancel
Save