Created
November 19, 2018 14:05
-
-
Save approximatenumber/4609dad5d3c63b4ea29d335acb8bb622 to your computer and use it in GitHub Desktop.
To remember: open PRs in Bitbucket from Jenkins job
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env groovy | |
payload = """ | |
{ | |
"title": "Updating Toolchain", | |
"description": "Need to deploy new versions of toolchain after succesful build.", | |
"state": "OPEN", | |
"open": true, | |
"closed": false, | |
"fromRef": { | |
"id": "refs/heads/${hashTag}", | |
"repository": { | |
"slug": "gnu-toolchain-gen", | |
"name": null, | |
"project": { | |
"key": "BDT" | |
} | |
} | |
}, | |
"toRef": { | |
"id": "refs/heads/develop", | |
"repository": { | |
"slug": "gnu-toolchain-gen", | |
"name": null, | |
"project": { | |
"key": "BDT" | |
} | |
} | |
}, | |
"locked": false, | |
"reviewers": [ | |
{ | |
"user": { | |
"name": "mamelnikov" | |
} | |
} | |
] | |
} | |
""" | |
@Library('ext-lib') | |
def builder = new helpers.Builder() | |
def notifier = new helpers.Notifier() | |
node { | |
properties( | |
[parameters([ | |
[$class: 'BuildDiscarderProperty', | |
strategy: [$class: 'LogRotator', numToKeepStr: "2" ]]] | |
) | |
try { | |
timestamps{ | |
stage('Create pull-request in SDK repo') { | |
sh "echo '${payload}' > payload.json" | |
prUrl = "https://bitbucket-url/rest/api/1.0/projects/DEVOPS/repos/test/pull-requests" | |
sh "curl -X POST \ | |
-u username:password \ | |
--header \"Content-Type: application/json\" \ | |
-H \"X-Atlassian-Token: no-check\" ${prURL} \ | |
-d @payload.json" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment