Skip to content

Instantly share code, notes, and snippets.

@hSATAC
Last active August 19, 2019 09:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hSATAC/d09981a4d7e95aad7701 to your computer and use it in GitHub Desktop.
Save hSATAC/d09981a4d7e95aad7701 to your computer and use it in GitHub Desktop.
Jenkins postbuild script assign github reviewer
#!/bin/bash
rand() {
echo $(( $1 * RANDOM / 32768 ))
}
rand_element () {
local -a th=("$@")
echo "${th[$( rand ${#th[@]} )]}"
}
reviewers=(hSATAC poga aar0nTw hanklin kerkerj)
committer=`ghi show $ghprbPullId | grep "opened this pull request" | awk '{ print substr($1,2); }'`
echo "Commiter: $committer"
echo -en "\n"
reviewers=(${reviewers[@]/$committer/})
echo "Reviewers: ${reviewers[@]}"
echo -en "\n"
reviewer="$(rand_element ${reviewers[@]})"
echo "Randomed Reviewer: $reviewer"
echo -en "\n"
ghi assign $ghprbPullId $reviewer
ghi comment -m "Please code review this PR: @$reviewer" $ghprbPullId
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment