Skip to content

Commit

Permalink
Fix branch failure on job_PostCommit_Website_Publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Myrvold committed Sep 28, 2018
1 parent fc38698 commit 9e1393c
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions website/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ def buildContentDir = "${project.rootDir}/build/website/generated-content"
def repoContentDir = "${project.rootDir}/website/generated-content"
def commitedChanges = false

def shell = { cmd ->
println cmd
exec {
executable 'sh'
args '-c', cmd
}
}

task buildDockerImage(type: Exec) {
inputs.files 'Gemfile', 'Gemfile.lock'
commandLine 'docker', 'build', '-t', dockerImageTag, '.'
Expand Down Expand Up @@ -116,7 +124,18 @@ task commitWebsite << {
def git = grgit.open()
// get the latest commit on master
def latestCommit = grgit.log(maxCommits: 1)[0].abbreviatedId

// Make sure we are sync'd to the gitbox head
if (!git.remote.list().find { it.name == 'test-upstream' }) {
println "Adding test-upstream remote"
git.remote.add(name: 'test-upstream',
url: 'https://gitbox.apache.org/repos/asf/beam.git')
}
shell "git fetch origin"
shell "git fetch test-upstream asf-site"
git.checkout(branch: 'asf-site')
shell "git reset --hard test-upstream/asf-site"
shell "git remote remove test-upstream"

// Delete the previous content.
git.remove(patterns: [ 'website/generated-content' ])
Expand All @@ -142,7 +161,6 @@ task commitWebsite << {
}
}


/*
* Pushes the asf-site branch commits.
*
Expand Down Expand Up @@ -170,19 +188,14 @@ task publishWebsite << {
println "Adding website-publish remote"
// Cannot authenticate to the default github uri, so specify gitbox.
git.remote.add(name: 'website-publish',
url: 'https://gitbox.apache.org/repos/asf/beam.git',
pushRefSpecs: ['refs/heads/asf-site'])
url: 'https://gitbox.apache.org/repos/asf/beam.git')
}

// Because git.push() fails to authenticate, run git push directly.
exec {
executable 'sh'
args '-c', "git push website-publish asf-site"
}
// Remove the remote. grgit does not have a remote.remove method.
exec {
executable 'sh'
args '-c', "git remote remove website-publish"
}
shell "git fetch website-publish asf-site"
shell "git merge website-publish/asf-site --no-edit"
shell "git push website-publish asf-site < /dev/null"
shell "git remote remove website-publish"
}

commitWebsite.dependsOn testWebsite
Expand Down

0 comments on commit 9e1393c

Please sign in to comment.