Skip to content

Instantly share code, notes, and snippets.

package examples
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueInputParametersImpl
import org.apache.log4j.Logger
def log = Logger.getLogger("com.onresolve.jira.groovy.MyScript")
def subTaskManager = ComponentAccessor.getSubTaskManager()
@jechlin
jechlin / ghViewInNav.js
Created September 11, 2013 20:07
Adds a "view in issue navigator" link for each sprint (not the backlog).
(function ($) {
$("span[data-fieldname='sprintMarkerName'],span[data-fieldname='sprintName']").livequery(function () {
var sprintHeader = $(this);
var issueCount = sprintHeader.parent().parent().parent().find("div.ghx-issue-count");
var html = issueCount.html();
// todo: localise
if (! /View in Issue Navigator/.test(html)) {
package examples
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.properties.APKeys
import com.atlassian.jira.web.session.currentusers.JiraUserSessionTracker
import groovy.json.JsonSlurper
import org.apache.commons.httpclient.Header
import org.apache.commons.httpclient.HttpClient
import org.apache.commons.httpclient.HttpMethod
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import org.apache.log4j.Logger
def log = Logger.getLogger("com.onresolve.jira.groovy.MyScript")
def MutableIssue issue = issue
log.debug(issue)
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.properties.APKeys
import org.apache.commons.httpclient.HttpClient
import org.apache.commons.httpclient.HttpMethod
import org.apache.commons.httpclient.methods.GetMethod
def client = new HttpClient()
def baseUrl = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)
HttpMethod method = new GetMethod("${baseUrl}/login.jsp")
def httpStatus = client.executeMethod(method)
@jechlin
jechlin / gist:5380119
Last active April 2, 2020 14:49
Display calculated custom fields on JIRA transition screens
<script type="text/javascript">
(function ($) {
// --------------------------------------- MANDATORY CONFIG ---------------------------------------
var fieldName = "Scripted Field" // display name - does not have to match the name of the field
var fieldId = "customfield_14013" // field Id
// --------------------------------------- END MANDATORY CONFIG -----------------------------------
function addCalculatedField(e, context) {
var $context = $(context);
package examples
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
Issue issue = issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
@jechlin
jechlin / gist:3172203
Created July 24, 2012 19:47
server shutdown log
java.lang.IllegalStateException: zip file closed
at java.util.zip.ZipFile.ensureOpen(ZipFile.java:416)
at java.util.zip.ZipFile.getEntry(ZipFile.java:161)
at java.util.jar.JarFile.getEntry(JarFile.java:208)
at org.apache.felix.framework.util.JarFileX.getEntry(JarFileX.java:61)
at org.apache.felix.framework.cache.JarContent.getEntryAsBytes(JarContent.java:120)
at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.findClass(ModuleImpl.java:1738)
at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:716)
at org.apache.felix.framework.ModuleImpl.access$200(ModuleImpl.java:73)
at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1690)
@jechlin
jechlin / gist:2762463
Created May 21, 2012 13:58
spit and sawdust confluence calendar upgrade
@Test
public void getAllCalendars() {
def sql = Sql.newInstance("jdbc:oracle:thin:@localhost:1521:XE", "confluence", "confluence")
def getCalsSql = """
SELECT CONTENT.SPACEID, SPACES.spacekey, SPACES.spacename, CONTENT.CONTENTID, CONTENT.title, CONTENT.LASTMODDATE
FROM CONTENT, BODYCONTENT, SPACES
WHERE PREVVER IS NULL AND
(CONTENTTYPE = 'PAGE' OR CONTENTTYPE = 'BLOGPOST')
@jechlin
jechlin / gist:2629735
Created May 7, 2012 19:04
prevent non admins editing the dashboard
(function($){
$(function(){
$.get(AJS.params.baseURL + "/rest/auth/1/session", function (data) {
userName = data.name;
// check groups
$.get(AJS.params.baseURL + "/rest/api/2.0.alpha1/user", {username: userName, expand: "groups"}, function (data) {
var groups = data.groups;
var groupItems = jQuery.map(groups.items, function (val, j) {return val.name});