Skip to content

Instantly share code, notes, and snippets.

/**
Author: kuisathaverat
Description: List ID and Description of all credentials on a Jenkins Instance.
**/
import com.cloudbees.plugins.credentials.Credentials
Set<Credentials> allCredentials = new HashSet<Credentials>();
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.Credentials.class
@kuisathaverat
kuisathaverat / disable_cli_sshd.groovy
Created May 3, 2017 09:36 — forked from hartzell/disable_cli_sshd.groovy
A groovy script to disable the built-in sshd server in Jenkins
// Drop this into init.groovy.d so that it gets executed at startup time.
// One could also use this script to explicitly set a port.
def inst = Jenkins.getInstance()
def sshDesc = inst.getDescriptor("org.jenkinsci.main.modules.sshd.SSHD")
sshDesc.setPort(-1)
sshDesc.getActualPort()
sshDesc.save()
@kuisathaverat
kuisathaverat / create-ssh-node.sh
Created November 16, 2016 09:59 — forked from Evildethow/create-ssh-node.sh
Jenkins: Create SSH node, using bash and curl
#!/usr/bin/env bash
set -o nounset -o errexit -o pipefail
usage() {
cat <<EOM
Usage:
$(basename $0) [OPTIONS]
$(basename $0) [ -j | --jenkins-url | -n | --node-name | -s | -d | --desc | --slave-home | -e | --executors | -sh | --ssh-host | -sp | --ssh-port
| -c | --cred-id | -l | --labels | -u | --user-id | -p | --password | -h | --help ]
@kuisathaverat
kuisathaverat / FindAllGroupsInFolders.groovy
Created June 21, 2016 22:03 — forked from joshshinn/FindAllGroupsInFolders.groovy
This will take a folder name, and find all RBAC groups/members in that folder and every folder under it
import nectar.plugins.rbac.groups.*
import com.cloudbees.hudson.plugins.folder.*
import com.cloudbees.jenkins.plugins.foldersplus.*
import com.cloudbees.hudson.plugins.folder.properties.FolderProxyGroupContainer
//Parent folder name to start with
String folderName = 'EmptyFolder'
folderItem = Jenkins.instance.getAllItems(Folder.class).find{it.name.equals(folderName)}
AbstractFolder < ? > folderAbs1 = AbstractFolder.class.cast(folderItem)
#!/bin/bash
IFS=$'\n\t'
set -euox pipefail
CNAME="$1"
FILE_PATH="$2"
TMPFILE="$(mktemp)"
docker exec "$CNAME" cat "$FILE_PATH" > "$TMPFILE"
#!/bin/bash
if [ $# -eq 0 ]; then
echo >&2 "Usage: jstackSeries <pid> [ <count> [ <delay> ] ]"
echo >&2 " Defaults: count = 10, delay = 1 (seconds)"
exit 1
fi
pid=$1 # required
count=${2:-10} # defaults to 10 times