Skip to content

Commit

Permalink
Change for other repo
Browse files Browse the repository at this point in the history
  • Loading branch information
definite committed Feb 15, 2018
1 parent 722b649 commit 52e6dd5
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 32 deletions.
77 changes: 49 additions & 28 deletions jenkins/maven-Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,26 @@ timestamps {
String WORK_ROOT = (env.WORK_ROOT) ?: "/home/jenkins/zanata-work-root"
String WORK_DIR = "${WORK_ROOT}/${REPO_NAME}"

def envArray = new ArrayList()

String releaseVersion = null
String artifactId = null

// chooses projects whose versions should be changed
// To be passed as -pl <Projects> in maven
String setPomVersionProjects = null

// List all artifacts to be released in sonatype nexus
// To be passed as -pl <Projects> in maven
String nexusStagingProjects = null

// pom.xml that has valid version
// e.g. parent/pom.xml in zanata-platform
String versionPomXml = "${WORK_DIR}/pom.xml"

boolean hasReleaseNotes = false


ansiColor('xterm') {
pipelineLibraryScmGit = new ScmGit(env, steps, "https://${ORG_BASE}/zanata-pipeline-library")
pipelineLibraryScmGit.init(PIPELINE_LIBRARY_BRANCH)
Expand Down Expand Up @@ -103,18 +120,38 @@ timestamps {
script: "bash $WORKSPACE/zanata-functions run get_artifact_id ${REPO_NAME}"
).trim()

withEnv(["WORK_ROOT=$WORK_ROOT","ZANATA_GIT_URL_PREFIX=https://${ORG_BASE}"]) {
envArray.addAll(
sh( returnStdout: true,
script: "sed -rn -e '/[A-Z_]*=/ s/^[^A-Z_]*([A-Z_]*=[^}]*)/\\1/p' $WORKSPACE/zanata-env.sh",
)?.split("\n")
)

envArray.addAll([
"WORK_ROOT=${WORK_ROOT}",
"ZANATA_RELEASE_MODE=${params.ZANATA_RELEASE_MODE}",
"ZANATA_GIT_URL_PREFIX=https://${ORG_BASE}",
])

if (params.ZANATA_RELEASE_MODE == 'dryRun') {
envArray.add("DryRunMode=1")
}

withEnv(envArray) {
// Different repo has different configuration
if (REPO_NAME == 'zanata-platform') {
setPomVersionProjects = env.PLATFORM_MAVEN_VERSION_PROJECT
nexusStagingProjects = env.PLATFORM_MAVEN_NEXUS_RELEASE_PROJECTS
versionPomXml = "${WORK_DIR}/parent/pom.xml"
hasReleaseNotes = true
}

sh("bash $WORKSPACE/zanata-functions run ensure_repo ${REPO_NAME}")
sh("bash $WORKSPACE/zanata-functions run checkout_branch ${REPO_NAME} ${PROJ_BRANCH} ${WORK_ROOT}")
dir(WORK_DIR) {
// git branch: PROJ_BRANCH, changelog: false, credentialsId: 'zanata-jenkins', poll: false, url: "https://${PROJ_BASE}.git"
// git branch: PROJ_BRANCH, changelog: false, credentialsId: 'zanata-jenkins', poll: false, url: "https://${PROJ_BASE}.git"

if (params.RELEASE_VERSION == 'auto') {
if (REPO_NAME == 'zanata-platform') {
releaseVersion = readMavenPom(file: "${WORK_DIR}/parent/pom.xml").getVersion().replaceAll('-SNAPSHOT', '')
} else {
releaseVersion = readMavenPom(file: "${WORK_DIR}/pom.xml").getVersion().replaceAll('-SNAPSHOT', '')
}
releaseVersion = readMavenPom(file: versionPomXml).getVersion().replaceAll('-SNAPSHOT', '')
} else {
releaseVersion = params.RELEASE_VERSION
}
Expand Down Expand Up @@ -146,28 +183,12 @@ timestamps {
}
}

def envArray = new ArrayList()
envArray.addAll(
sh( returnStdout: true,
script: "sed -rn -e '/[A-Z_]*=/ s/^[^A-Z_]*([A-Z_]*=[^}]*)/\\1/p' $WORKSPACE/zanata-env.sh",
)?.split("\n")
)

envArray.addAll([
"WORK_ROOT=${WORK_ROOT}",
"ZANATA_RELEASE_MODE=${params.ZANATA_RELEASE_MODE}",
])

if (params.ZANATA_RELEASE_MODE == 'dryRun') {
envArray.add("DryRunMode=1")
}

withEnv(envArray) {
String developmentVersion = null
String tagName = null

dir (WORK_DIR) {
if (REPO_NAME == 'zanata-platform'){
if (hasReleaseNotes){
stage('ReleaseNotes') {
notify.startBuilding()
String releaseNoteVersion = releaseVersion.replaceAll(/[-.]/, '')
Expand All @@ -192,7 +213,7 @@ timestamps {

stage('SetReleaseVersion') {
sh(returnStatus: true,
script: "bash $WORKSPACE/zanata-pom-set-version ${artifactId}- $releaseVersion $PLATFORM_MAVEN_VERSION_PROJECT",
script: "bash $WORKSPACE/zanata-pom-set-version ${artifactId}- $releaseVersion $setPomVersionProjects",
)
}
// We cannot use org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:deploy here
Expand All @@ -202,14 +223,14 @@ timestamps {
// sh "bash $WORKSPACE/zanata-nexus $PLATFORM_MAVEN_NEXUS_RELEASE_PROJECTS"
//}
stage('NexusStaging') {
sh "bash $WORKSPACE/zanata-nexus-staging $PLATFORM_MAVEN_NEXUS_RELEASE_PROJECTS"
sh "bash $WORKSPACE/zanata-nexus-staging $nexusStagingProjects"
}
stage('NexusRelease') {
sh "bash $WORKSPACE/zanata-nexus-release -p $PLATFORM_MAVEN_NEXUS_RELEASE_PROJECTS"
sh "bash $WORKSPACE/zanata-nexus-release -p $nexusStagingProjects"
}
stage('SetSnapshotVersion') {
sh(returnStatus: true,
script: "bash $WORKSPACE/zanata-pom-set-version ${artifactId}- $developmentVersion $PLATFORM_MAVEN_VERSION_PROJECT",
script: "bash $WORKSPACE/zanata-pom-set-version ${artifactId}- $developmentVersion $setPomVersionProjects"
)
withCredentials([
[$class: 'UsernamePasswordMultiBinding',
Expand Down
3 changes: 2 additions & 1 deletion zanata-nexus
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export DryRunMode

Projects="${1-}"

if [[ -n $Projects ]]; then

if [[ -n $Projects && $Project != 'null' ]]; then
ProjectOpts="-pl $Projects"
else
ProjectOpts=""
Expand Down
3 changes: 2 additions & 1 deletion zanata-nexus-release
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ export DryRunMode

Projects="${1-}"

if [[ -n $Projects ]]; then
if [[ -n $Projects && $Project != 'null' ]]; then
ProjectOpts="-pl $Projects"
else
ProjectOpts=""
fi



## This function runs the staging plugin to fetch the repository id and state into these variables:
## StagingRepositoryId
## StagingRepositoryState
Expand Down
3 changes: 2 additions & 1 deletion zanata-nexus-staging
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ shift $((OPTIND-1))

Projects="${1-}"

if [[ -n $Projects ]]; then
if [[ -n $Projects && $Project != 'null' ]]; then
ProjectOpts="-pl $Projects"
else
ProjectOpts=""
fi


if [[ $ZANATA_RELEASE_MODE == testBuild ]]; then
Goal=verify
else
Expand Down
2 changes: 1 addition & 1 deletion zanata-pom-set-version
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ else
ScmTag="$TagPrefix$Version"
fi

if [[ -n $Projects ]]; then
if [[ -n $Projects && $Project != 'null' ]]; then
ProjectOpts="-pl $Projects"
else
ProjectOpts=""
Expand Down

0 comments on commit 52e6dd5

Please sign in to comment.