Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix abort job on CI commit #4253

Merged
merged 1 commit into from
Nov 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,29 @@ def clean() {
sh 'rm -rf ${HOME}/workspace/testgeomapfish'
}

def abort_ci() {
// Makes sure Jenkins will not build his own commit
COMMITTER = sh(returnStdout: true, script: "git show --no-patch --format='%ae' HEAD").trim()
if (COMMITTER == 'ci@camptocamp.com') {
// Return here instead of throwing error to keep the build "green"
currentBuild.result = 'SUCCESS'
return true
}
return false
}

dockerBuild {
timeout(time: 2, unit: 'HOURS') {
try {
stage('Clean') {
checkout scm
if (abort_ci()) { return }
sh 'docker --version'
sh 'docker-compose --version'
clean()
}
stage('Build') {
// Makes sure Jenkins will not build his own commit
if (sh(returnStdout: true, script: "git show --no-patch --format='%ae' HEAD") == 'ci@camptocamp.com') {
exit(0)
}
if (abort_ci()) { return }
sh 'git config user.email ci@camptocamp.com'
sh 'git config user.name CI'
sh 'git branch --delete --force ${BRANCH_NAME} || true'
Expand All @@ -55,6 +64,7 @@ dockerBuild {
sh './docker-run travis/short-make build'
}
stage('Tests') {
if (abort_ci()) { return }
parallel 'Lint and test c2cgeoportal': {
sh './docker-run travis/empty-make help'
sh 'bash -c "test \\"`./docker-run id`\\" == \\"uid=0(root) gid=0(root) groups=0(root)\\""'
Expand Down Expand Up @@ -192,6 +202,7 @@ dockerBuild {
}
}
stage('Test Upgrade') {
if (abort_ci()) { return }
parallel 'Tests upgrades Docker': {
sh 'travis/test-upgrade-convert.sh docker ${HOME}/workspace'
sh 'travis/test-upgrade-convert.sh tonondocker ${HOME}/workspace'
Expand All @@ -204,6 +215,7 @@ dockerBuild {
}
}
stage('Publish') {
if (abort_ci()) { return }
parallel 'Push to Docker hub': {
withCredentials([string(credentialsId: 'docker-hub', variable: 'DOCKER_PASSWORD')]) {
env.DOCKER_PASSWORD = DOCKER_PASSWORD
Expand All @@ -226,12 +238,14 @@ dockerBuild {
}
}
stage('Publish documentation to GitHub.io') {
if (abort_ci()) { return }
sshagent (credentials: ['c2c-infra-ci']) {
sh 'travis/doc.sh'
}
}
} finally {
stage('Clean') {
if (abort_ci()) { return }
sh 'docker stop geomapfish-db'
sh 'docker rm --volumes geomapfish-db'
clean()
Expand Down