Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
definite committed Nov 24, 2017
1 parent f20ef44 commit abe1838
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions jenkins/maven-Jenkinsfile
Expand Up @@ -4,14 +4,13 @@
*/

@Field
public static final String PROJ_URL = 'https://github.com/zanata/zanata-scripts'
public static final String REPO_NAME = "zanata-platform"

// TODO: restore to master
@Field
public static final String ZANATA_SCRIPTS_BRANCH = 'ZNTA-1803-maven-release-pipeline'
public static final String PROJ_BASE = 'github.com/zanata/zanata-platform'

@Field
public static final String REPO_NAME = "zanata-platform"
public static final String ZANATA_SCRIPTS_BASE = 'github.com/zanata/zanata-scripts'

@Field
public static final String ARTIFACT_ID = "platform"
Expand Down Expand Up @@ -39,6 +38,13 @@ public static final String NEXUS_STAGING_OPTIONS = '-e -DnexusUrl=https://oss.so
@Field
public static final String NEXUS_STAGING_PLUGIN = 'org.sonatype.plugins:nexus-staging-maven-plugin'

// TODO: restore to master
@Field
public static final String ZANATA_SCRIPTS_BRANCH = 'ZNTA-1803-maven-release-pipeline'

@Field
public static final String PROJ_BRANCH = 'release'

@Field
public static final String PIPELINE_LIBRARY_BRANCH = 'v0.3.1'

Expand All @@ -53,6 +59,9 @@ import groovy.transform.Field
@Field
def pipelineLibraryScmGit

@Field
def zanataScriptScmGit

@Field
def mainScmGit

Expand Down Expand Up @@ -87,10 +96,12 @@ timestamps {
ansicolor {
pipelineLibraryScmGit = new ScmGit(env, steps, 'https://github.com/zanata/zanata-pipeline-library')
pipelineLibraryScmGit.init(PIPELINE_LIBRARY_BRANCH)
mainScmGit = new ScmGit(env, steps, PROJ_URL)
mainScmGit.init(ZANATA_SCRIPTS_BRANCH)
zanataScriptsScmGit = new ScmGit(env, steps, "https://$ZANATA_SCRIPTS_BASE")
zanataScriptsScmGit.init(ZANATA_SCRIPTS_BRANCH)
mainScmGit = new ScmGit(env, steps, "https://$PROJ_BASE")
mainScmGit.init(PROJ_BRANCH)
notify = new Notifier(env, steps, currentBuild,
pipelineLibraryScmGit, mainScmGit, (env.GITHUB_COMMIT_CONTEXT) ?: 'Jenkinsfile',
pipelineLibraryScmGit, mainScmGit, 'zanata-scripts-release',
)

jobName = env.JOB_NAME
Expand All @@ -104,7 +115,7 @@ timestamps {
]
],
[$class: 'GithubProjectProperty',
projectUrlStr: PROJ_URL
projectUrlStr: "https://${PROJ_BASE}"
],
[$class: 'ParametersDefinitionProperty',
parameterDefinitions: [
Expand Down Expand Up @@ -138,12 +149,12 @@ timestamps {
checkout scm

sh "bash $WORKSPACE/zanata-functions run ensure_repo $REPO_NAME"
sh "bash $WORKSPACE/zanata-functions run checkout_branch $REPO_NAME release $WORK_ROOT"
sh "bash $WORKSPACE/zanata-functions run checkout_branch $REPO_NAME $PROJ_BRANCH $WORK_ROOT"
// Match the origin/release

// Remove tag (possibly from a failed build)
dir("${WORK_ROOT}/${REPO_NAME}") {
sh "git reset --hard origin/release"
sh "git reset --hard origin/$PROJ_BRANCH"
sh "git clean -fdx"
if (params.RELEASE_VERSION == 'auto') {
releaseVersion = readMavenPom(file: "${WORK_ROOT}/${REPO_NAME}/parent/pom.xml").getVersion().replaceAll('-SNAPSHOT', '')
Expand Down Expand Up @@ -173,6 +184,7 @@ timestamps {
dir ("${WORK_ROOT}/${REPO_NAME}") {
String releaseNoteVersion = releaseVersion.replaceAll('-.*','')
stage('ReleaseNotes') {
notify.startBuilding()
echo "releaseNoteVersion: $releaseNoteVersion"
def releaseNoteStatus = sh(returnStatus: true,
script: "bash $WORKSPACE/zanata-release-notes-prepend -j $ARTIFACT_ID $releaseNoteVersion",
Expand Down Expand Up @@ -232,6 +244,14 @@ timestamps {
sh "sed -i -e 's|<tag>.*</tag>|<tag>HEAD</tag>|' \$(find . -name pom.xml | xargs )"
sh "./mvnw $MAVEN_EXTRA_OPTIONS $MAVEN_RELEASE_OPTIONS -pl $MAVEN_VERSION_PROJECTS versions:set -DnewVersion=$developmentVersion"
sh "./mvnw scm:checkin -Dmessage='chore(version): set version $developmentVersion' -DpushChanges=true"
withCredentials([
[$class: 'UsernamePasswordMultiBinding',
credentialsId: 'zanata-jenkins',
usernameVariable: 'GIT_USERNAME', passwordVariable: 'GITHUB_OAUTH2_TOKEN'
]
]) {
sh "git push https://$GIT_USERNAME:$GITHUB_OAUTH2_TOKEN@${PROJ_BASE.git $tag"
sh "git push --follow-tags origin release"
}
}
Expand Down

0 comments on commit abe1838

Please sign in to comment.