diff options
author | deepshikhaaa <deepshikhakhandelwal8@gmail.com> | 2017-08-03 10:10:27 +0530 |
---|---|---|
committer | Nigel Babu <nigelb@redhat.com> | 2017-08-16 14:15:22 +0000 |
commit | 0bdaba0cf24347598c8d55e6b82a0ab64d83b1f0 (patch) | |
tree | 2e1ba083527027f5ffe2eccd7dd8fef2097c573e /build-gluster-org | |
parent | a704ed52cbeffa0d0a29829ad17feac5c2a056a3 (diff) |
Job for posting comments on bugzilla through Jenkins
Change-Id: Ie866f7a1faa8629cc35667cc42b21b2afe7946ce
Diffstat (limited to 'build-gluster-org')
-rw-r--r-- | build-gluster-org/jobs/bugzilla-post.yml | 48 | ||||
-rw-r--r-- | build-gluster-org/scripts/bugzilla-post.sh | 57 |
2 files changed, 105 insertions, 0 deletions
diff --git a/build-gluster-org/jobs/bugzilla-post.yml b/build-gluster-org/jobs/bugzilla-post.yml new file mode 100644 index 0000000..b337f8f --- /dev/null +++ b/build-gluster-org/jobs/bugzilla-post.yml @@ -0,0 +1,48 @@ +- job: + name: bugzilla-post + node: bugzilla + description: Reporting the status of bugs on Bugzilla + project-type: freestyle + + scm: + - glusterfs + + triggers: + - gerrit: + trigger-on: + - patchset-created-event: + exclude-drafts: false + exclude-trivial-rebase: false + exclude-no-code-change: false + - change-merged-event + server-name: review.gluster.org_for-smoke-jobs + override-votes: 1 + gerrit-build-failed-verified-value: 0 + gerrit-build-unstable-verified-value: 0 + gerrit-build-notbuilt-verified-value: 0 + projects: + - project-compare-type: 'PLAIN' + project-pattern: 'glusterfs' + branches: + - branch-compare-type: 'ANT' + branch-pattern: '**' + + parameters: + - string: + default: refs/heads/master + description: 'For review 12345 and patch set 6, this will be refs/changes/45/12345/6. Default: Tip of master' + name: GERRIT_REFSPEC + - string: + default: master + description: 'Name of the branch you want to build from. We usually build from master' + name: GERRIT_BRANCH + - string: + default: 'true' + description: 'A parameter named DRY_RUN, defaults to true' + name: DRY_RUN + + builders: + - shell: !include-raw: ../scripts/bugzilla-post.sh + + wrappers: + - timestamps diff --git a/build-gluster-org/scripts/bugzilla-post.sh b/build-gluster-org/scripts/bugzilla-post.sh new file mode 100644 index 0000000..79d09d3 --- /dev/null +++ b/build-gluster-org/scripts/bugzilla-post.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +function commit_message_edited() +{ + if [ "$GERRIT_PATCHSET_NUMBER" != "1" ]; then + OLD_PATCHSET_NUM=$GERRIT_PATCHSET_NUMBER-1 + old_bugid=$(curl -X GET https://review.gluster.org/changes/${GERRIT_PROJECT}~${GERRIT_BRANCH}~${GERRIT_CHANGE_ID}/revisions/$OLD_PATCHSET_NUM/commit | grep subject | awk -F'"' '{print $4}' | sed 's/\\n/\'$'\n''/g' | grep -i '^bug: ' | awk '{print $2}') + if [ "$bugid" == "$old_bugid" ]; then + return; + fi + fi +} + +function update_bugzilla() +{ + bugid=$(echo $GERRIT_CHANGE_COMMIT_MESSAGE | base64 -d | grep -i '^bug: ' | awk '{print $2}'); + [ -z "$bugid" ] && return; + + product=$(bugzilla query -b $bugid --outputformat='%{product}'); + if [ "$product" != "GlusterFS" ]; then + echo "Wrong product: $product" >&2; + return 1; + fi + + #checking the type of event + if [ "$GERRIT_EVENT_TYPE" != "change-merged" ]; then + if [ "$GERRIT_PATCHSET_NUMBER" == "1" ]; then + run bugzilla modify $bugid --comment="REVIEW: $GERRIT_CHANGE_URL ($GERRIT_CHANGE_SUBJECT) posted (#$GERRIT_PATCHSET_NUMBER) for review on $GERRIT_BRANCH by $GERRIT_PATCHSET_UPLOADER_NAME"; + else + commit_message_edited; + run bugzilla modify $bugid --comment="REVISION POSTED: $GERRIT_CHANGE_URL ($GERRIT_CHANGE_SUBJECT) posted (#$GERRIT_PATCHSET_NUMBER) for review on $GERRIT_BRANCH by $GERRIT_PATCHSET_UPLOADER_NAME"; + fi + else + run bugzilla modify $bugid --comment="COMMIT: $GERRIT_CHANGE_URL committed in $GERRIT_BRANCH by $GERRIT_SUBMITTER `echo; echo -------------; echo;` $GERRIT_CHANGE_COMMIT_MESSAGE"; + fi +} + +function run() +{ + if [[ "$DRY_RUN" ]]; then + echo $@ + else + $@ + fi +} + + +function main() +{ + if [ "$GERRIT_PROJECT" != "glusterfs" ]; then + return; + fi + update_bugzilla; +} + +main; + |