Created
March 10, 2016 15:14
-
-
Save mattyb149/5cf18b070a9fb844a140 to your computer and use it in GitHub Desktop.
A Groovy script to match Apache Jira cases with GitHub pull requests. Defaults to Apache NiFi and uses GITHUB_TOKEN env variable for OAuth
This file contains hidden or 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
| @Grab('org.kohsuke:github-api:1.73') | |
| import org.kohsuke.github.* | |
| def slurper = new groovy.json.JsonSlurper() | |
| def PR_REGEX = /([nN][iI][fF][iI][ -][0-9]+).*/ | |
| def g = GitHub.connectUsingOAuth('github.com', System.getenv('GITHUB_TOKEN')) | |
| def pulls = g.getRepository('apache/nifi').getPullRequests(GHIssueState.OPEN) | |
| pulls.each { pr -> | |
| def m = pr.title =~ PR_REGEX | |
| def prStatus = '' | |
| if(m) { | |
| def jiraCase = m[0][1].toUpperCase().replace(' ','-') | |
| def jiraUrl = "http://issues.apache.org/jira/rest/api/2/issue/${jiraCase}" | |
| def jiraObj = slurper.parseText(new URL(jiraUrl).text) | |
| prStatus = "${jiraObj.fields.fixVersions*.name}" | |
| } | |
| println "PR ${pr.number}: ${pr.title} ${prStatus} (${pr.url})" | |
| } | |
| println "Total: ${pulls.size}" | |
| 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment