Skip to content

Commit

Permalink
fix(maven-release): nexus-staging testBuild should run install to avo…
Browse files Browse the repository at this point in the history
…id downloading undeployed artifacts

* Add build-tools back to MAVEN_PARENT_PROJECT
* Add back projects that are required for zanata WAR

fix(function): git_detached_merge_branch: pull before merge
feat(function): new function branch_forced_pull
  • Loading branch information
definite committed May 24, 2018
1 parent f8ae674 commit b2249e9
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 12 deletions.
19 changes: 13 additions & 6 deletions jenkins/maven-Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ timestamps {
case 0: // EXIT_OK
// ReleaseNotes updated. Git commit is done by zanata-release-notes-prepend
break
case 21: // EXIT_ERROR_UNKNOWN_VERSION
// Jira does not have this version
break
case 40: // EXIT_RETURN_FALSE
case 21: // EXIT_ERROR_UNKNOWN_VERSION
// Jira does not have this version
break
case 40: // EXIT_RETURN_FALSE
// ReleaseNotes does not changed
break
default:
Expand Down Expand Up @@ -207,9 +207,9 @@ timestamps {
}
stage('SetSnapshotVersion') {
sh(returnStatus: true,
script: "bash $WORKSPACE/zanata-pom-set-version $developmentVersion"
script: "bash $WORKSPACE/zanata-pom-set-version $developmentVersion",
)
sh "bash $WORKSPACE/zanata-functions run git_detached_merge_branch ${PROJ_BRANCH}"
sh "bash $WORKSPACE/zanata-functions run git_detached_merge_branch ${PROJ_BRANCH}"

withCredentials([
[$class: 'UsernamePasswordMultiBinding',
Expand All @@ -219,6 +219,13 @@ timestamps {
]) {
if ( params.ZANATA_RELEASE_MODE == '') {
sh "git push --follow-tags https://$GIT_USERNAME:$GITHUB_OAUTH2_TOKEN@${PROJ_BASE} ${PROJ_BRANCH}"
// Merge master
if (PROJ_BRANCH != 'master') {
sh "git checkout master"
sh "bash $WORKSPACE/zanata-functions run branch_forced_pull"
sh "git merge ${PROJ_BRANCH} -Xours"
sh "git push"
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions zanata-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ MAVEN_NEXUS_STAGING_PLUGIN="org.sonatype.plugins:nexus-staging-maven-plugin"
MAVEN_NEXUS_STAGING_OPTIONS="-DnexusUrl=https://oss.sonatype.org/ -DserverId=sonatype-staging"

## zanata-platform
PLATFORM_MAVEN_PARENT_PROJECT="parent"
PLATFORM_MAVEN_NEXUS_RELEASE_PROJECTS="!server,!server/functional-test,!server/gwt-editor,!server/gwt-shared,!server/gwt-test,!server/security-common,!server/services,!server/zanata-frontend,!server/zanata-liquibase,!server/zanata-model,!server/zanata-model-test,!server/zanata-test-war,!server/zanata-war"
PLATFORM_MAVEN_PARENT_PROJECT="build-tools,parent"
PLATFORM_MAVEN_NEXUS_RELEASE_PROJECTS="!server/functional-test,!server/zanata-test-war"
PLATFORM_MAVEN_RELEASE_PROFILES="release"
PLATFORM_STAGING_REPOSITORY="orgzanata"
PLATFORM_RELEASE_NOTES_FILE="docs/release-notes.md"
Expand Down
23 changes: 20 additions & 3 deletions zanata-functions
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ echo_stderr(){
###
### branch_checkout <repoName> <branch> [parentDir]
### checkout <branch> for <repoName>.
### Note that this won't change to the repoName directory.
### Note that:
### 1. this won't cd to the repoName directory.
### 2. If local branch will be override by remote branch
branch_checkout(){
local repoName=$1
local branch=$2
Expand All @@ -161,8 +163,7 @@ branch_checkout(){
cd ${parentDir}/${repoName}
git remote update origin > /dev/stderr
git checkout ${branch} > /dev/stderr
git pull > /dev/stderr
git reset --hard origin/$branch > /dev/stderr
branch_forced_pull
cd - > /dev/stderr
}

Expand Down Expand Up @@ -191,6 +192,21 @@ branch_does_exist(){
return $EXIT_RETURN_FALSE
}

###
### branch_forced_pull [remote]
### Withdraw local changes and pull the remote,
### which, by default, is 'origin'
### Note that function does nothing to a detached HEAD
branch_forced_pull(){
local branch=$(branch_get_current)
local remote=${1:-origin}
if [[ $branch = 'HEAD' ]] ;then
return
fi
git fetch $remote $branch > /dev/stderr
git reset --hard "$remote/$branch" > /dev/stderr
}

###
### branch_get_current
### Return current branch name, or HEAD when detach.
Expand Down Expand Up @@ -648,6 +664,7 @@ git_detached_merge_branch(){
if [[ $(branch_get_current) = HEAD ]]; then
git branch $tmpBranch $commitSha
git checkout $branch
branch_forced_pull
git merge $tmpBranch
git branch -D $tmpBranch
fi
Expand Down
7 changes: 7 additions & 0 deletions zanata-maven-release
Original file line number Diff line number Diff line change
Expand Up @@ -285,5 +285,12 @@ $ScriptDir/zanata-pom-set-version "$DevelopmentVersion"
if [[ -z $ZANATA_RELEASE_MODE ]]; then
## Push the SNAPSHOT commit
run_command git push --follow-tags origin $WorkingBranch
if [[ $WorkingBranch != 'master' ]] ;then
## Merge to master
run_command git checkout master
run_commnad branch_forced_pull
run_command git merge $WorkingBranch -Xours
run_command git push
fi
fi

4 changes: 3 additions & 1 deletion zanata-nexus-staging
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ else
fi

if [[ $ZANATA_RELEASE_MODE == testBuild ]]; then
Goal=verify
## Use install
## so following steps will not looking for undeployed artifacts.
Goal=install
else
Goal=deploy
fi
Expand Down

0 comments on commit b2249e9

Please sign in to comment.