[jbossts-issues] [JBoss JIRA] (JBTM-2996) Change the Narayana CI jobs to consider membership of PR author

Ondra Chaloupka (JIRA) issues at jboss.org
Fri Feb 23 06:38:00 EST 2018

    [ https://issues.jboss.org/browse/JBTM-2996?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13537462#comment-13537462 ] 

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

export GIT_ACCOUNT=jbosstm
export GIT_REPO=narayana

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" != "" ]
        JSON="{ \"body\": \"$1\" }"
        curl -d "$JSON" -ujbosstm-bot:$BOT_PASSWORD https://api.github.com/repos/$GIT_ACCOUNT/$GIT_REPO/issues/$PULL_NUMBER/comments
        echo "Not a pull request, so not commenting"

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/comments)
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
  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

> 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

More information about the jbossts-issues mailing list