Skip to content

Commit

Permalink
fix variables
Browse files Browse the repository at this point in the history
  • Loading branch information
definite committed Feb 6, 2018
1 parent a4f9559 commit 77266e3
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions jenkins/maven-Jenkinsfile
Expand Up @@ -100,18 +100,14 @@ timestamps {
properties(projectProperties)
}

String releaseVersion = params.RELEASE_VERSION
String developmentVersion = null
String artifactId = REPO_NAME.replaceAll('zanata-','')
String tagName = "${artifactId}-${releaseVersion}"

if (params.ZANATA_RELEASE_MODE != "" ){
currentBuild.displayName = currentBuild.displayName + " [${params.ZANATA_RELEASE_MODE}]"
}

def envArray = new ArrayList()
envArray.addAll(
sh( returnStdout: true,
sh( returnStdout: true,
script: "curl -q https://raw.githubusercontent.com/zanata/zanata-scripts/$ZANATA_SCRIPTS_BRANCH/zanata-env.sh | sed -rn -e '/[A-Z_]*=/ s/^[^A-Z_]*([A-Z_]*=[^}]*)/\\1/p' ",
)?.split("\n")
)
Expand All @@ -128,6 +124,11 @@ timestamps {
}

withEnv(envArray) {
String artifactId = REPO_NAME.replaceAll('zanata-','')
String releaseVersion = null
String developmentVersion = null
String tagName = null

echo "MAVEN_RELEASE_OPTIONS=$env.MAVEN_RELEASE_OPTIONS"
stage('Checkout') {
// Checkout and test GPG
Expand All @@ -146,7 +147,10 @@ timestamps {
sh "git clean -fdx"
if (params.RELEASE_VERSION == 'auto') {
releaseVersion = readMavenPom(file: "${WORK_ROOT}/${REPO_NAME}/parent/pom.xml").getVersion().replaceAll('-SNAPSHOT', '')
} else {
releaseVersion = params.RELEASE_VERSION
}
tagName = "${artifactId}-${releaseVersion}"

developmentVersion = (sh(returnStdout: true,
script: "bash $WORKSPACE/zanata-functions run version_next $releaseVersion").trim()) + '-SNAPSHOT'
Expand All @@ -159,9 +163,10 @@ timestamps {
error "tag ${tagName} is already in remote"
}

String localTagLine = sh(returnStdout: true,
script: "git ls-remote . refs/tags/${tagName}")?.trim()
if ( localTagLine ){
def tagExistExitStatus = sh(returnStatus: true,
script: "git show-ref ${tagName}")
if ( tagExistExitStatus == 0 ){
// Tag exists
sh "git tag -d $tagName"
}
}
Expand Down

0 comments on commit 77266e3

Please sign in to comment.