Simple collection of Groovy scripts to help me maintain some Jenkins systems.
See also https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console
import hudson.model.Action | |
import com.cloudbees.workflow.flownode.FlowNodeUtil | |
import com.cloudbees.workflow.rest.external.StatusExt | |
import org.jenkinsci.plugins.workflow.graph.FlowNode | |
import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode | |
import org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode | |
import org.jenkinsci.plugins.workflow.actions.LabelAction |
import java.net.URL; | |
import java.security.SecureRandom; | |
import java.security.cert.CertificateException; | |
import java.security.cert.X509Certificate; | |
import javax.net.ssl.HostnameVerifier; | |
import javax.net.ssl.HttpsURLConnection; | |
import javax.net.ssl.KeyManager; | |
import javax.net.ssl.SSLContext; | |
import javax.net.ssl.SSLSession; | |
import javax.net.ssl.TrustManager; |
def getProjectName() { | |
return 'JenkinsPipeline' | |
} | |
def getJDKVersion() { | |
return 'jdk1.8.0_101' | |
} | |
def getMavenConfig() { | |
return 'maven-config' |
import jenkins.* | |
import hudson.* | |
import com.cloudbees.plugins.credentials.* | |
import com.cloudbees.plugins.credentials.common.* | |
import com.cloudbees.plugins.credentials.domains.* | |
import com.cloudbees.jenkins.plugins.sshcredentials.impl.* | |
import hudson.plugins.sshslaves.*; | |
import hudson.model.* | |
import jenkins.model.* | |
import hudson.security.* |
# The command finds the most recent tag that is reachable from a commit. | |
# If the tag points to the commit, then only the tag is shown. | |
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object | |
# and the abbreviated object name of the most recent commit. | |
git describe | |
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix: | |
git describe --abbrev=0 | |
# other examples |
#!/usr/bin/env ruby | |
require 'base64' | |
require 'digest' | |
require 'openssl' | |
# Author: @thesubtlety | |
# Decrypts Jenkins 2 encrypted strings, code change introduced around Jenkins ver 2.44 | |
# Based off work by juyeong, https://gist.github.com/juyeong/081379bd1ddb3754ed51ab8b8e535f7c |
Simple collection of Groovy scripts to help me maintain some Jenkins systems.
See also https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console
#!/bin/bash | |
# compiled from https://docs.docker.com/engine/installation/linux/debian/#/debian-jessie-80-64-bit | |
sudo apt-get update | |
sudo apt-get dist-upgrade -y | |
sudo apt-get install apt-transport-https ca-certificates -y | |
sudo sh -c "echo deb https://apt.dockerproject.org/repo debian-jessie main > /etc/apt/sources.list.d/docker.list" | |
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D |
#!/bin/bash | |
# Original script in: | |
# http://blog.sonatype.com/2011/01/downloading-artifacts-from-nexus-with-bash/#.VPW0c1PF_v9 | |
# Adapted for Nexus 3 | |
# Define Nexus Configuration | |
NEXUS_BASE=http://repository.example.com:8081/nexus | |
usage() |
// URL for Jira's REST API for issues | |
var getIssueURL = "https://[Your Jira host]/rest/api/2/issue/"; | |
// Personally I prefer the script to handle request failures, hence muteHTTPExceptions = true | |
var fetchArgs = { | |
contentType: "application/json", | |
headers: {"Authorization":"Basic [Your BASE64 Encoded user:pass]"}, | |
muteHttpExceptions : true | |
}; |