Created
June 26, 2019 15:21
-
-
Save daniel-sc/9cb61827dd8af9da7af66fe51f05f939 to your computer and use it in GitHub Desktop.
bookmarklet to automatically create jira subtasks for testing
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
// convert via https://mrcoles.com/bookmarklet/ | |
var tasks = prompt('Tasks mit Kommas abgetrennt eingeben:', 'Test planen,Testdaten definieren,Tests erstellen,Test durchführen & dokumentieren').split(','); | |
var match = window.location.pathname.match(/[A-Z]+-[0-9]+/); | |
if (match[0]) { | |
var task = match[0]; | |
var match = task.match(/[A-Z]+/); | |
var project = match[0]; | |
var promises = []; | |
for (var i = 0; i < tasks.length; i++) { | |
promises.push($.ajax({ | |
contentType: 'application/json', | |
dataType: 'json', | |
type: "POST", | |
url: "/rest/api/2/issue", | |
data: JSON.stringify({ | |
"fields": { | |
"project": {"key": project}, | |
"parent": {"key": task}, | |
"summary": tasks[i], | |
"issuetype": {"id": "5"}, | |
"timetracking": {"originalEstimate": (tasks[i] === 'Test planen' ? '0.5h' : "2h")} | |
} | |
}) | |
})); | |
} | |
$.when.apply($, promises).then(function () { | |
JIRA.Messages.showReloadSuccessMsg('Testtasks erfolgreich erstellt.'); | |
JIRA.Issue.reload() | |
}, function () { | |
JIRA.Messages.showReloadErrorMsg('Fehler beim erstellen der Testtasks. (Fehler in der JS Console ersichtlich.)'); | |
console.log(arguments); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment