Skip to content

Instantly share code, notes, and snippets.

View kmadel's full-sized avatar

Kurt Madel kmadel

View GitHub Profile
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: nfs-client-provisioner
spec:
replicas: 1
strategy:
type: Recreate
template:
metadata:
@kmadel
kmadel / clusterAutoscalerDeployment.yml
Last active June 4, 2018 14:05
clusterAutoscalerDeployment.yml for Autoscaling Jenkins Agents with Kubernetes on kurtmadel.com
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
k8s-addon: cluster-autoscaler.addons.k8s.io
app: cluster-autoscaler
name: cluster-autoscaler
namespace: kube-system
---
for (cause in currentBuild.rawBuild.getCauses()) {
if (cause instanceof Cause.UpstreamCause) {
def upstreamProjectName = cause.getUpstreamProject()
echo upstreamProjectName
def job = hudson.model.Hudson.instance.getItem(upstreamProjectName)
def build = job.getBuildByNumber(cause.getUpstreamBuild())
echo build.buildVariableResolver.resolve("version")
}
}
import com.cloudbees.opscenter.analytics.reporter.items.AnalyticsJobProperty
def createdDateCompare = Date.parse("MM/dd/yyyy","05/25/2016")
jobs = Jenkins.instance.getAllItems();
def numberOfWorkflowJobs = 0
jobs.each { j ->
if (j instanceof org.jenkinsci.plugins.workflow.job.WorkflowJob) {
def analyticsJobProperty = (AnalyticsJobProperty)j.getProperty(AnalyticsJobProperty.class)
if(analyticsJobProperty != null && analyticsJobProperty.created < createdDateCompare.time) {
#!/bin/bash
set -e
UPDATES_URL="http://updates.jenkins-ci.org/download/plugins/"
if [ $# -lt 2 ]; then
echo "USAGE: $0 plugin-list-file destination-directory"
exit 1
fi
/*** BEGIN META {
"name" : "Count executors",
"comment" : "Shows the total number of nodes and executors on Jenkins",
"parameters" : [ ],
"core": "1.350",
"authors" : [
{ name : "Andy Pemberton" }
]
} END META**/
import jenkins.model.Jenkins
@kmadel
kmadel / Jenkinsfile
Created November 30, 2015 19:33 — forked from chinshr/Jenkinsfile
Best of Jenkinsfile, a collection of useful workflow scripts ready to be copied into your Jenkinsfile on a per use basis.
#!groovy
# Best of Jenkinsfile
# `Jenkinsfile` is a groovy script DSL for defining CI/CD workflows for Jenkins
node {
}
@kmadel
kmadel / workflow.gdsl
Created August 27, 2015 18:23
Jenkins Workflow Autocomplete for Intellij
/*
Author: Gary Clayburg
This file allows IntelliJ IDEA to perform basic syntax checking and code completion for
Jenkins workflow groovy scripts. https://github.com/jenkinsci/workflow-plugin
These methods are supported
sh
readFile
node
echo
import hudson.model.*
def payloadString = build.buildVariableResolver.resolve("payload")
payloadObject = new groovy.json.JsonSlurper().parseText(payloadString)
targetCommit = payloadObject.pull_request.head.sha
build.addAction(new ParametersAction(new StringParameterValue('targetCommit', targetCommit)))