Skip to content

Instantly share code, notes, and snippets.

View dodok1's full-sized avatar

Jozef Kotlar dodok1

View GitHub Profile
@dodok1
dodok1 / upm_deploy_addon.sh
Last active November 20, 2020 01:15
script to deploy add-on to UPM
echo source this script using . to define function below
echo script requires that packages 'curl' and 'jq' are installed
echo . upm_deploy_addon.sh
echo upm_deploy http://localhost:8080/jira admin:passwd path_to_addon.jar
upm_deploy() {
TOKEN=$(curl -s -I -u $2 $1/rest/plugins/1.0/|grep ^upm-token|cut -c12-|tr -d '[:space:]')
out=$(curl -s -X POST -u $2 -H "Accept: application/vnd.atl.plugins.installed+json" -F plugin=@$3 $1/rest/plugins/1.0/?token=$TOKEN)
while [ "$(echo $out | jq -r .status.done)" = "false" ]; do
sleep 1; echo -n .
@dodok1
dodok1 / upm-dump-addons.sh
Last active April 6, 2018 13:35
List installed addongs
#!/bin/bash
####
# extractUserAddons.sh <baseurl> <userid> <passwd>
#
BASEURL=$1
USERID=$2
PASSWD=$3
if [ -z "$BASEURL" -o -z "$USERID" ]; then
@dodok1
dodok1 / gist:3d26ab45c66a951b89a3
Created December 5, 2014 13:02
Scriptrunner - Ukážka práce s SQL
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import groovy.sql.Sql
import java.sql.Driver
// spristupnenie customfieldu
def cfNumber = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Number")
if (cfNumber == null) {
return "ERROR: neznamy customfield"
}
@dodok1
dodok1 / gist:7925037
Last active December 22, 2019 15:19 — forked from anonymous/gist:7925024
Improved ordering and full JQL as tooltip
<script type='text/javascript'>
var refreshJqlHistoryPane = function() {
var localHistory = localStorage.getItem('jqlHistory');
if(localHistory){
var history = JSON.parse(localHistory);
var historyEntries = history.map(function(jql){
var display = jql;
if(display.length > 25){
display = display.substr(0,22) + "...";
}
@dodok1
dodok1 / gist:6525310
Created September 11, 2013 15:32
clear notification scheme for all projects
import com.atlassian.jira.component.ComponentAccessor
def pm = ComponentAccessor.getProjectManager()
def nsm = ComponentAccessor.getNotificationSchemeManager()
pm.getProjectObjects().each{project->nsm.removeSchemesFromProject(project)}
@dodok1
dodok1 / gist:4692296
Created February 1, 2013 16:19
JIRA 5.2 with CAS authentification patch
diff --git a/atlassian-jira/WEB-INF/classes/jpm.xml b/atlassian-jira/WEB-INF/classes/jpm.xml
--- a/atlassian-jira/WEB-INF/classes/jpm.xml
+++ b/atlassian-jira/WEB-INF/classes/jpm.xml
@@ -246,7 +246,7 @@
<default-value>false</default-value>
<type>boolean</type>
<admin-editable>false</admin-editable>
- <sysadmin-editable>false</sysadmin-editable>
+ <sysadmin-editable>true</sysadmin-editable>
</property>
@dodok1
dodok1 / gist:4619132
Created January 24, 2013 09:30
Getting LDAP parameters in JIRA is easy
import com.atlassian.jira.component.ComponentAccessor
def cds = ComponentAccessor.getComponent(com.atlassian.crowd.embedded.api.CrowdDirectoryService)
def attrs = cds.findAllDirectories().find{it.isActive() && it.attributes.keySet().contains('ldap.url')}?.attributes
if (attrs) attrs.collect{k,v->"$k = $v"}.join("\n")
@dodok1
dodok1 / count-xpm-colours.groovy
Created January 17, 2013 11:42
script to count colours in hierarchy of XPM files
def p = ~/.*\.pm/ // pattern for files
def c = /". c ([0-9A-Za-z#]+)",/ // pattern for colour definition
def count = [:] // count of colours
// recursing into current directory
new File(".").eachDirRecurse { d->
d.eachFileMatch(p) { f->
f.eachLine { l->
m = (l =~ c)
if (m.matches()) count[m[0][1]] = count.containsKey(m[0][1]) ? count[m[0][1]]+1 : 1
}
@dodok1
dodok1 / gist:4352500
Last active February 19, 2018 19:02
prototype for confluence content parsing # Get Confluence XML Schema # Put confluence.dtd and xhtml-*.ent to your working directory # Try attached groovy script
import groovy.xml.XmlUtil
def content=new File(args[0]).getText()
def slurper = new XmlSlurper(false,false)
def prefix = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ac:confluence SYSTEM "confluence.dtd">
<ac:confluence xmlns:ac="http://www.atlassian.com/schema/confluence/4/ac/" xmlns:ri="http://www.atlassian.com/schema/confluence/4/ri/" xmlns="http://www.atlassian.com/schema/confluence/4/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.atlassian.com/schema/confluence/4/ac/ confluence.xsd">
"""
def suffix = "</ac:confluence>"
def xml = slurper.parseText(prefix+content+suffix)
# Usage: cas-get.sh {url} {username} {password} # If you have any errors try removing the redirects to get more information
# The service to be called, and a url-encoded version (the url encoding isn't perfect, if you're encoding complex stuff you may wish to replace with a different method)
DEST="$1"
ENCODED_DEST=`echo "$DEST" | perl -p -e 's/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg' | sed 's/%2E/./g' | sed 's/%0A//g'`
#IP Addresses or hostnames are fine here
CAS_HOSTNAME=team.eea.sk
#Authentication details. This script only supports username/password login, but curl can handle certificate login if required
USERNAME=$2