Skip to content

Commit

Permalink
[BEAM-4496] Fix branch fetch failure on job_PostCommit_Website_Publish (
Browse files Browse the repository at this point in the history
  • Loading branch information
alanmyrvold authored and swegner committed Sep 29, 2018
1 parent 5e7c27f commit bf69c25
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 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,10 @@ task commitWebsite << {
def git = grgit.open()
// get the latest commit on master
def latestCommit = grgit.log(maxCommits: 1)[0].abbreviatedId

shell "git fetch origin asf-site"
git.checkout(branch: 'asf-site')
shell "git reset --hard origin/asf-site"

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


/*
* Pushes the asf-site branch commits.
*
Expand All @@ -166,23 +176,9 @@ task publishWebsite << {
println 'No changes to push'
return
}
if (!git.remote.list().find { it.name == 'website-publish' }) {
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'])
}

// 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 push https://gitbox.apache.org/repos/asf/beam.git asf-site"
}

commitWebsite.dependsOn testWebsite
Expand Down

0 comments on commit bf69c25

Please sign in to comment.