Simple collection of Groovy scripts to help me maintain some Jenkins systems.
See also https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console
Please comment & let me know if you have a fork / fixes you'd like to include.
{ | |
"annotations": { | |
"list": [ | |
{ | |
"builtIn": 1, | |
"datasource": "-- Grafana --", | |
"enable": true, | |
"hide": true, | |
"iconColor": "rgba(0, 211, 255, 1)", | |
"name": "Annotations & Alerts", |
#!/usr/bin/env bash | |
function walk() { | |
for secret in $(vault list $1 | tail -n +3) | |
do | |
if [[ ${secret} == *"/" ]] ; then | |
walk "${1}${secret}" | |
else | |
echo "${1}${secret}" | |
fi |
Jenkins.instance.queue.items.findAll { !it.task.name.contains("Extenda") }.each { | |
println "Cancel ${it.task.name}" | |
Jenkins.instance.queue.cancel(it.task) | |
} | |
Jenkins.instance.items.each { | |
stopJobs(it) | |
} | |
def stopJobs(job) { | |
if (job in jenkins.branch.OrganizationFolder) { | |
// Git behaves well so no need to traverse it. |
#!groovy | |
import groovy.json.JsonOutput | |
import groovy.json.JsonSlurper | |
def label = "mypod-${UUID.randomUUID().toString()}" | |
podTemplate(label: label, yaml: """ | |
spec: | |
containers: | |
- name: mvn | |
image: maven:3.3.9-jdk-8 |
#!/usr/bin/env groovy | |
// https://github.com/freebsd/freebsd-ci/blob/master/scripts/build/build-test.groovy | |
// http://stackoverflow.com/a/40294220 | |
// https://JENKINS_HOST/scriptApproval/ - for script approval | |
import java.util.Date | |
def isMaster = env.BRANCH_NAME == 'master' | |
def isDevelop = env.BRANCH_NAME == 'develop' |
#!/usr/bin/python | |
""" Ansible Inventory Generated From Netbox | |
Author: Stanley Karunditu <stanley@linuxsimba.com> | |
License: MIT | |
Requirements: | |
* use netbox device roles that result in hyphenated role names. E.g |
func ComputeHmac256(message string, secret string) string { | |
key := []byte(secret) | |
h := hmac.New(sha256.New, key) | |
h.Write([]byte(message)) | |
return base64.StdEncoding.EncodeToString(h.Sum(nil)) | |
} |
#!/usr/bin/python | |
DOCUMENTATION = ''' | |
--- | |
module: github_repo | |
short_description: Manage your repos on Github | |
''' | |
EXAMPLES = ''' | |
- name: Create a github Repo |
{# style 1 - long form #} | |
{% if filepath == '/var/opt/tomcat_1' %} | |
{% set tomcat_value = tomcat_1_value %} | |
{% else %} | |
{% set tomcat_value = tomcat_2_value %} | |
{% endif %} | |
{# style 2 - short form #} | |
{% set tomcat_value = tomcat_1_value if (filepath == '/var/opt/tomcat_1') else tomcat_2_value %} |
Simple collection of Groovy scripts to help me maintain some Jenkins systems.
See also https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console
Please comment & let me know if you have a fork / fixes you'd like to include.