From b2249e954892de27a3757b446d4f7325be184ddd Mon Sep 17 00:00:00 2001 From: Ding-Yi Chen Date: Wed, 23 May 2018 11:31:13 +1000 Subject: [PATCH] fix(maven-release): nexus-staging testBuild should run install to avoid 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 --- jenkins/maven-Jenkinsfile | 19 +++++++++++++------ zanata-env.sh | 4 ++-- zanata-functions | 23 ++++++++++++++++++++--- zanata-maven-release | 7 +++++++ zanata-nexus-staging | 4 +++- 5 files changed, 45 insertions(+), 12 deletions(-) diff --git a/jenkins/maven-Jenkinsfile b/jenkins/maven-Jenkinsfile index be76c98..8195d29 100644 --- a/jenkins/maven-Jenkinsfile +++ b/jenkins/maven-Jenkinsfile @@ -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: @@ -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', @@ -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" + } } } } diff --git a/zanata-env.sh b/zanata-env.sh index d6904a1..35497f6 100644 --- a/zanata-env.sh +++ b/zanata-env.sh @@ -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" diff --git a/zanata-functions b/zanata-functions index 4602e2e..48c23cb 100755 --- a/zanata-functions +++ b/zanata-functions @@ -152,7 +152,9 @@ echo_stderr(){ ### ### branch_checkout [parentDir] ### checkout for . -### 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 @@ -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 } @@ -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. @@ -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 diff --git a/zanata-maven-release b/zanata-maven-release index e82c779..2d07fd6 100755 --- a/zanata-maven-release +++ b/zanata-maven-release @@ -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 diff --git a/zanata-nexus-staging b/zanata-nexus-staging index f0bb395..a91919f 100755 --- a/zanata-nexus-staging +++ b/zanata-nexus-staging @@ -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