Skip to content

Commit

Permalink
Check a PR has been committed using git signoff (NVIDIA#439)
Browse files Browse the repository at this point in the history
* Check a PR has been committed using git signoff

Pre-merge build fails without seeing a `-s` signoff from anyone committing to a PR.
If the author of a commit adds a single commit with a `-s`, that will be sufficient for the pre-merge build to pass.

Signed-off-by: Tim Liu <[email protected]>

* Update jenkins/Jenkinsfile.premerge

Co-authored-by: Jason Lowe <[email protected]>

* Append '|| true' to avoid  failing to match to cause the pipeline failure

Co-authored-by: Tim Liu <[email protected]>
Co-authored-by: Sameer Raheja <[email protected]>
Co-authored-by: Jason Lowe <[email protected]>
  • Loading branch information
4 people authored Aug 3, 2020
1 parent d478fa6 commit 4ae6405
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions jenkins/Jenkinsfile.premerge
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ pipeline {
agent { label 'docker-gpu' }
steps {
script {
//Check if a PR has been committed using git signoff
if (!isSignedOff()) {
error "Signed-off-by check FAILED"
}

def CUDA_NAME=sh(returnStdout: true,
script: '. jenkins/version-def.sh>&2 && echo -n $CUDA_CLASSIFIER | sed "s/-/./g"')
def IMAGE_NAME="$ARTIFACTORY_NAME/sw-spark-docker/plugin:dev-ubuntu16-$CUDA_NAME"
Expand All @@ -72,3 +77,24 @@ pipeline {
}
} // end of stages
} // end of pipeline

boolean isSignedOff() {
def target_rev = sh(returnStdout: true,
script: "git rev-parse refs/remotes/origin/${ghprbTargetBranch}").trim()
def revs_arr = sh(returnStdout: true,
script: "git log ${target_rev}..${ghprbActualCommit} --pretty=format:%h").split()

def signed_off = false
for( String commit : revs_arr ) {
def signed_log = sh(returnStdout: true,
script: "git show ${commit} --shortstat | grep 'Signed-off-by' || true")
echo "commit: ${commit}, signed_log: ${signed_log}"
// Find `Signed-off-by` comment in one of the commits
if (signed_log?.trim()) {
signed_off = true
break;
}
}

return signed_off
}

0 comments on commit 4ae6405

Please sign in to comment.