Last active
August 19, 2019 09:13
-
-
Save hSATAC/d09981a4d7e95aad7701 to your computer and use it in GitHub Desktop.
Jenkins postbuild script assign github reviewer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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