Skip to content

Instantly share code, notes, and snippets.

package com.onresolve.jira.groovy.canned.admin
import com.onresolve.jira.groovy.canned.CannedScript
import org.apache.log4j.Category
import com.atlassian.jira.util.ErrorCollection
import com.onresolve.jira.groovy.canned.utils.CannedScriptUtils
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.builder.JqlQueryBuilder
import com.atlassian.jira.issue.search.SearchRequest
package package.name.removed
import com.atlassian.crowd.directory.DelegatedAuthenticationDirectory;
import com.atlassian.crowd.directory.loader.DirectoryInstanceLoader;
import com.atlassian.crowd.embedded.api.Directory;
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.crowd.exception.DirectoryInstantiationException;
import com.atlassian.crowd.exception.OperationFailedException;
import com.atlassian.crowd.exception.UserNotFoundException;
import com.atlassian.crowd.manager.directory.DirectoryManager;
package examples
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.MutableIssue
import groovy.sql.Sql
import org.ofbiz.core.entity.ConnectionFactory
import org.ofbiz.core.entity.DelegatorInterface
import java.sql.Connection
@jechlin
jechlin / gist:2561925
Created April 30, 2012 19:34
add watcher script
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.search.SearchRequest
import com.atlassian.jira.jql.builder.JqlQueryBuilder
import com.atlassian.jira.project.Project
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.query.Query
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.search.SearchRequest
import com.atlassian.jira.jql.builder.JqlQueryBuilder
import com.atlassian.jira.project.Project
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.query.Query
@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});
@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: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)
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: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);