Skip to content

Instantly share code, notes, and snippets.

View chuikoaleksandr's full-sized avatar

Chuiko Aleksandr chuikoaleksandr

  • @Mail.Ru
  • Russia
View GitHub Profile
@chuikoaleksandr
chuikoaleksandr / validator-example2.groovy
Created November 13, 2018 14:21
Jira MyGroovy simple validator comment example
import com.opensymphony.workflow.InvalidInputException
def MESSAGE_ERROR = "You must enter a comment."
if(!transientVars["comment"]) {
throw new InvalidInputException("comment", MESSAGE_ERROR)
}
@chuikoaleksandr
chuikoaleksandr / Jira-JsIncluder-example-set assignee.js
Created January 11, 2019 14:22
Atlasteam, Jira, plugin JsIncluder. Set assignee. For https://atlasteam.ru/?p=1925
(function ($) {
setAssignee('admin');
function setAssignee(name) {
var setValue = name;
var $field = $("#assignee");
$.get(AJS.params.baseURL + "/rest/api/latest/user", {
username: setValue
}, function (data) {
$("#assignee-single-select").remove();
@chuikoaleksandr
chuikoaleksandr / test gist.html
Last active May 12, 2021 08:31
test gist.html
<html>
<script>
alert(123)
</script>
123123
</html>
@chuikoaleksandr
chuikoaleksandr / JIRA transition.groovy
Last active May 6, 2020 16:59
ScriptRunner for JIRA
import com.atlassian.jira.component.ComponentAccessor
def doTransition(issue, int actionId, user){
def issueService = ComponentAccessor.getIssueService()
def issueInputParameters = issueService.newIssueInputParameters();
def transitionValidationResult = issueService.validateTransition(user, issue.id, actionId, issueInputParameters);
if (transitionValidationResult.isValid()){
issueService.transition(user, transitionValidationResult);
return true
} else {
@chuikoaleksandr
chuikoaleksandr / Jira-JsIncluder-example-set fixVersion.js
Last active September 3, 2019 16:13
Atlasteam, Jira, plugin JsIncluder. Set fixVersion. For https://atlasteam.ru/?p=1925
function setFixVersion(version) {
var val = AJS.$("#fixVersions").val();
val = val ? val : [];
val.push(version.id);
AJS.$("#fixVersions").val(val);
AJS.$("#fixVersions-textarea").val(version.name).blur();
}
var versions = [
{
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.type.EventDispatchOption
def issue = event.issue
def cfСomplexPriority = ComponentAccessor.customFieldManager.getCustomFieldObject(10001)//todo set MyGroovy calculate field id
switch (issue.getCustomFieldValue(cfСomplexPriority)) {
case [0d, 1d, 3d]:
issue.setPriorityId("5")
break
@chuikoaleksandr
chuikoaleksandr / Jira-JsIncluder-example-set component.js
Created January 11, 2019 14:34
Atlasteam, Jira, plugin JsIncluder. Set component. For https://atlasteam.ru/?p=1925
function setComponent(component) {
var val = AJS.$("#components").val();
val = val ? val : []
val.push(component.id)
AJS.$("#components").val(val);
AJS.$("#components-textarea").val(component.name).blur();
}
var components = [
{
@chuikoaleksandr
chuikoaleksandr / Jira-JsIncluder-example-set select value.js
Created January 11, 2019 14:25
Atlasteam, Jira, plugin JsIncluder. Set select value. For https://atlasteam.ru/?p=1925
//select
AJS.$('#customfield_10001').val(10002)
//multiselect
AJS.$('#customfield_10000').val([10000, 10001])
//cascade select
AJS.$('#customfield_10002').val(10004).change()
AJS.$('#customfield_10002\\:1').val('10005')
@chuikoaleksandr
chuikoaleksandr / Jira-JsIncluder-example-remove resolution.js
Created January 11, 2019 14:14
Atlasteam, Jira, plugin JsIncluder. Remove resolution For https://atlasteam.ru/?p=1925
AJS.$('#resolution > option[value=10000]').remove()
import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException
def getCustomFieldValue(issue, Long fieldId) {
issue.getCustomFieldValue(ComponentAccessor.customFieldManager.getCustomFieldObject(fieldId))
}
if (!getCustomFieldValue(issue, 10000)) {
throw new InvalidInputException("Please indicate the reason for the increased priority")
}