def do_merge_pull_request(pr, build_number, config): """The given pull build passed and needs to be merged. """ github_info = GithubInfo( config['github.owner'], config['github.project'], config['github.username'], config['github.token'], ) jenkins_info = JenkinsInfo( config['jenkins.merge.url'], config['jenkins.merge.job'], config['jenkins.merge.token'], ) build_url = generate_build_url(build_number, jenkins_info) try: result = merge_pull_request(pr, build_url, github_info) if result['merged']: return result['message'] else: raise GithubError('Failed to merge: {0}'.format(result['message'])) except GithubError as exc: return 'Failed to add comment: {0}'.format(exc)
def mark_pull_request_build_failed(pr, build_number, failure_message, config): """The given pull request failed to build. Comment on the pull request to alert the devs of this issue. """ github_info = GithubInfo( config['github.owner'], config['github.project'], config['github.username'], config['github.token'], ) jenkins_info = JenkinsInfo( config['jenkins.merge.url'], config['jenkins.merge.job'], config['jenkins.merge.token'], ) pull_request = get_pull_request(pr, github_info) build_url = generate_build_url(build_number, jenkins_info) try: comment = pull_request_build_failed( pull_request, build_url, failure_message, github_info ) return comment['url'] except GithubError as exc: return 'Failed to add comment: {0}'.format(exc)
def mark_pull_request_build_failed(pr, build_number, failure_message, config): """The given pull request failed to build. Comment on the pull request to alert the devs of this issue. """ github_info = GithubInfo( config['github.owner'], config['github.project'], config['github.username'], config['github.token'], ) jenkins_info = JenkinsInfo( config['jenkins.merge.url'], config['jenkins.merge.job'], config['jenkins.merge.token'], ) pull_request = get_pull_request(pr, github_info) build_url = generate_build_url(build_number, jenkins_info) try: comment = pull_request_build_failed(pull_request, build_url, failure_message, github_info) return comment['url'] except GithubError as exc: return 'Failed to add comment: {0}'.format(exc)
def do_merge_pull_request(pr, build_number, config): """The given pull build passed and needs to be merged. """ github_info = GithubInfo( config['github.owner'], config['github.project'], config['github.username'], config['github.token'], ) jenkins_info = JenkinsInfo( config['jenkins.merge.url'], config['jenkins.merge.job'], config['jenkins.merge.token'], ) build_url = generate_build_url(build_number, jenkins_info) try: result = merge_pull_request( pr, build_url, github_info ) if result['merged']: return result['message'] else: raise GithubError( 'Failed to merge: {0}'.format(result['message'])) except GithubError as exc: return 'Failed to add comment: {0}'.format(exc)