Skip to content

Commit

Permalink
Merge pull request #25 from zvercodebender/master
Browse files Browse the repository at this point in the history
Update Pull Request webhook
  • Loading branch information
Rick Broker authored Feb 7, 2020
2 parents 7ad4fc7 + 7888039 commit 7b5e021
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 28 deletions.
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
language: java
jdk: openjdk8
before_install:
- openssl aes-256-cbc -K $encrypted_e5bd312d25bf_key -iv $encrypted_e5bd312d25bf_iv
-in deploy_key.enc -out /tmp/deploy_key -d
- eval "$(ssh-agent -s)"
- echo -e "Host $DIST_HOST\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- chmod 600 /tmp/deploy_key
- ssh-add /tmp/deploy_key
deploy:
- provider: releases
api-key:
Expand All @@ -17,6 +10,13 @@ deploy:
on:
tags: true
repo: xebialabs-community/xlr-bitbucket-plugin
before_install:
- openssl aes-256-cbc -K $encrypted_e5bd312d25bf_key -iv $encrypted_e5bd312d25bf_iv
-in deploy_key.enc -out /tmp/deploy_key -d
- eval "$(ssh-agent -s)"
- echo -e "Host $DIST_HOST\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- chmod 600 /tmp/deploy_key
- ssh-add /tmp/deploy_key
- provider: script
skip_cleanup: true
script: rsync --update -raz -i $TRAVIS_BUILD_DIR/build/libs/*.jar $DIST_USER@$DIST_HOST:$DIST_PATH/${TRAVIS_REPO_SLUG#*/}/
Expand Down
50 changes: 29 additions & 21 deletions src/main/resources/stash/pr_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,40 @@

from com.xebialabs.xlrelease.api.v1.forms import StartRelease
from java.util import HashMap

import sys
import json
import ast

def handle_request(event, template_filter = None):

print event
print template_filter
logger.info(str(event))
#try:
# if event["push"]:
# logger.info("Found push event for template %s " % template_filter)
# handle_push_event(event, template_filter)
#except:
# e = sys.exc_info()[1]
# msg = ("Could not parse payload, check your Bitbucket Webhook "
# "configuration. Error: %s. Payload:\n%s" % (e, event))
# logger.warn(msg)
# return
logger.info(json.dumps(event, indent=4, sort_keys=True))
try:
if event["pullRequest"]:
logger.info("Found push event for template %s " % template_filter)
logger.info(json.dumps(event['pullRequest'], indent=4, sort_keys=True))
handle_push_event(event['pullRequest'], template_filter)
except:
e = sys.exc_info()[1]
msg = ("Could not parse payload, check your Bitbucket Webhook "
"configuration. Error: %s. Payload:\n%s" % (e, event))
logger.warn(msg)
return

def handle_push_event(event, template_filter):
proj_name = event['proj']
repo_name = event["repository"]
pr_number = event['pr_number']
pr_title = event['pr_title']
comment = event['comment']
source_hash = event['source_hash']
target_hash = event['target_hash']
proj_name = event['fromRef']['repository']['project']['key']
logger.debug("proj_name = %s" % proj_name)
repo_name = event['fromRef']["repository"]['name']
logger.debug("repo_name = %s" % repo_name)
pr_number = event['id']
logger.debug("pr_number = %s" % pr_number)
pr_title = event['title']
logger.debug("pr_title = %s" % pr_title)
comment = event['title']
logger.debug("comment = %s" % comment)
source_hash = event['fromRef']['latestCommit']
logger.debug("source_hash = %s" % source_hash)
target_hash = event['toRef']['latestCommit']
logger.debug("target_hash = %s" % target_hash)
start_pr_release(proj_name, repo_name, pr_number, pr_title, comment, source_hash,target_hash, template_filter)


Expand Down

0 comments on commit 7b5e021

Please sign in to comment.