[
https://issues.jboss.org/browse/JBTM-2996?page=com.atlassian.jira.plugin....
]
Ondra Chaloupka edited comment on JBTM-2996 at 2/23/18 6:37 AM:
----------------------------------------------------------------
I distributed the change to all _pulls_ `-poller` jobs
was (Author: ochaloup):
I distributed the change to all _pulls_ `-poller` jobs. I ended up with the following
```bash
export GIT_ACCOUNT=jbosstm
export GIT_REPO=narayana
export COMMENT_ON_PULL=1
function comment_on_pull {
if [ "$COMMENT_ON_PULL" = "" ]; then return; fi
PULL_NUMBER=$(echo $GIT_BRANCH | awk -F 'pull' '{ print $2 }' | awk -F
'/' '{ print $2 }')
if [ "$PULL_NUMBER" != "" ]
then
JSON="{ \"body\": \"$1\" }"
curl -d "$JSON" -ujbosstm-bot:$BOT_PASSWORD
https://api.github.com/repos/$GIT_ACCOUNT/$GIT_REPO/issues/$PULL_NUMBER/c...
else
echo "Not a pull request, so not commenting"
fi
}
PULL_NUMBER=$(echo $GIT_BRANCH | awk -F 'pull' '{ print $2 }' | awk -F
'/' '{ print $2 }')
PULL_DESCRIPTION=$(curl -ujbosstm-bot:$BOT_PASSWORD -s
https://api.github.com/repos/$GIT_ACCOUNT/$GIT_REPO/pulls/$PULL_NUMBER)
#
https://developer.github.com/v4/reference/enum/commentauthorassociation/
PR_AUTHOR_MEMBERSHIP=$(echo $PULL_DESCRIPTION | sed
's/.*"author_association": "\([^,]*\)".*/\1/')
COMMENTS=$(curl -ujbosstm-bot:$BOT_PASSWORD -s
https://api.github.com/repos/$GIT_ACCOUNT/$GIT_REPO/issues/$PULL_NUMBER/c...)
MEMBERS_COMMENTS=$(printf '%s' "$COMMENTS" | awk
'/"author_association"|"body"/ { if(/MEMBER|COLLABORATOR|OWNER/)
{getline; print;} }')
# if author of the PR is permitted or if the comment on the PR contains text
'TESTIT' written by one of the members
if [[ ! $PR_AUTHOR_MEMBERSHIP =~ MEMBER|COLLABORATOR|OWNER|CONTRIBUTOR ]] && [[ !
$MEMBERS_COMMENTS =~ TESTIT ]]; then
echo "Author of pull request '$PULL_NUMBER' is not member of github jbosstm
organization or member comment needs to contain text 'TESTIT'"
printf "membership of PR:\n%s\n" "$PR_AUTHOR_MEMBERSHIP"
printf "members comments:\n%s\n" "$MEMBERS_COMMENTS"
comment_on_pull ':warning: CI not started.\n\nAuthor is not the '$GIT_REPO'
contributor, members of $GIT_ACCOUNT can write comment of text `TESTIT` to permit PR being
run.'
exit 0
fi
```
Change the Narayana CI jobs to consider membership of PR author
---------------------------------------------------------------
Key: JBTM-2996
URL:
https://issues.jboss.org/browse/JBTM-2996
Project: JBoss Transaction Manager
Issue Type: Feature Request
Components: Build System
Affects Versions: 5.7.2.Final
Reporter: Ondra Chaloupka
Assignee: Ondra Chaloupka
Priority: Minor
It would be good to start using gihub webhooks instead of a poller jenkins cron job.
Configure the triggers in Jenkins and webhook on github and consider using the plugin
https://wiki.jenkins.io/display/JENKINS/GitHub+pull+request+builder+plugin
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)