Skip to content

Instantly share code, notes, and snippets.

@epishan
epishan / jira_get_users_by_project_role
Created February 22, 2019 10:12
Gets list of users for given project Role for all projects in given project category
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.security.roles.ProjectRole
import com.atlassian.jira.security.roles.ProjectRoleActors
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.ProjectCategory
@epishan
epishan / jira_remove_inactive_schemes.groovy
Last active March 7, 2021 09:19
[JIRA] Remove inactive (unassigned) Workflow Schemes
import com.atlassian.jira.component.ComponentAccessor
def schemeManager = ComponentAccessor.workflowSchemeManager
def sb = new StringBuffer()
def schemes = schemeManager.getAssignableSchemes()
if(schemes != null) {
schemes.each {
if (schemeManager.isActive(it)) {
sb.append("|||||| Skipping active wf scheme: ${it.name} \n")
@epishan
epishan / jira_delete_worlflow.groovy
Created June 12, 2017 09:27
JIRA: Delete inactive workflow without linked schema
import com.atlassian.jira.component.ComponentAccessor
def workflowManager = ComponentAccessor.workflowManager
def schemeManager = ComponentAccessor.workflowSchemeManager
def sb = new StringBuffer()
// get 2 weeks ago date
today = new java.sql.Timestamp(new Date().getTime() - 120960000)
@epishan
epishan / run.tpl
Last active June 12, 2017 13:40 — forked from efrecon/run.tpl
[docker] `docker inspect` template to regenerate the `docker run` command that created a container
docker run \
--name={{.Name}} \
{{range $e := .Config.Env}}--env="{{$e}}" \
{{end}}{{range $p, $conf := .NetworkSettings.Ports}}-p {{(index $conf 0).HostIp}}:{{(index $conf 0).HostPort}}:{{$p}} \
{{end}}{{range $v := .HostConfig.VolumesFrom}}--volumes-from="{{.}}" \
{{end}}{{range $v := .HostConfig.Binds}}--volume="{{.}}" \
{{end}}{{range $l, $v := .Config.Labels}}--label "{{$l}}"="{{$v}}" \
{{end}}{{range $v := .HostConfig.CapAdd}}--cap-add {{.}} \
{{end}}{{range $v := .HostConfig.CapDrop}}--cap-drop {{.}} \
{{end}}{{range $d := .HostConfig.Devices}}--device={{(index $d).PathOnHost}}:{{(index $d).PathInContainer}}:{{(index $d).CgroupPermissions}} \
// this script will reuse GIT_BRANCH variable from the last successful job, if current BRANCH parameter is empty
def branch="$BRANCH"
println "currentJob --> ${currentJob}"
println "currentBuild --> ${currentBuild}"
if (branch=="") {
try {
println "setting BRANCH from the last build"
import hudson.model.*
def q = Jenkins.instance.queue
def JOB_PATTERN = ~/^tools.merge_master.*$/; //find all jobs starting with "MY_JOB".
(q.items.findAll { it.task.name =~ JOB_PATTERN }).each {
println ("Cancelling task " + it.task.name);
q.cancel(it.task)
}
// Groovy script to rename job in Hudson
import hudson.model.*;
def JOB_PATTERN = ~/^GO.*.deploy_container.staging*$/; //find all jobs starting with "MY_JOB".
def NEW_PART = "_NEW"
(Hudson.instance.items.findAll { job -> job.name =~ JOB_PATTERN }).each { job_to_update ->
if (job_to_update.name =~ "GO.bob_api.*") {
return;
}
@epishan
epishan / disable_job.groovy
Last active June 12, 2017 13:41 — forked from sergey-epishkin-lzd/delete_job.groovy
[jenlins] Jenkins jobs cleanup
// Groovy script to disable job in Hudson
import hudson.model.*;
def JOB_PATTERN = ~/^GO.*.deploy*.staging2$/; //find all jobs starting with "MY_JOB".
(Hudson.instance.items.findAll { job -> job.name =~ JOB_PATTERN }).each { job_to_update ->
if (job_to_update.name =~ "^\$") {
return;
}
else {
@epishan
epishan / generate_views.groovy
Last active June 14, 2016 10:45
[groovy] Jenkins generate nested vies
import jenkins.model.*
import hudson.model.ListView
import hudson.model.*
import hudson.plugins.nested_view.*
def name_parent = 'GO'
def name_component = 'Component1_VIEW'
def name_repo = 'repo_regex'
def viewObj = Jenkins.instance.getView(name_parent) //lvl 1
package main
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"net/http"
"strconv"
)