From 49b0532d241a1e8fa2a9a000e129554e8c476b6c Mon Sep 17 00:00:00 2001 From: Matt Rendina Date: Mon, 7 Jan 2019 15:16:33 -0500 Subject: Apply 'testing' label to notification issues if label exists in repo. (#28) --- vars/utils.groovy | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'vars') diff --git a/vars/utils.groovy b/vars/utils.groovy index 849d036..ef651dc 100644 --- a/vars/utils.groovy +++ b/vars/utils.groovy @@ -14,8 +14,19 @@ import org.kohsuke.github.GitHub def postGithubIssue(reponame, username, password, subject, message) { def github = GitHub.connectUsingPassword("${username}", "${password}") def repo = github.getRepository(reponame) + // Determine if the 'testing' label exists in the repo. If it does, + // apply it to the new issue. + def labels = repo.listLabels() + def labelnames = [] + for (label in labels) { + labelnames.add(label.getName()) + } + def labelname = 'testing' def ibuilder = repo.createIssue(subject) ibuilder.body(message) + if (labelname in labelnames) { + ibuilder.label(labelname) + } ibuilder.create() } -- cgit