Skip to content

Instantly share code, notes, and snippets.

View jeffnelson's full-sized avatar

Jeff Nelson jeffnelson

  • Target Corporation - Supply Chain
  • Minneapolis, MN
View GitHub Profile
@jeffnelson
jeffnelson / getUpstreamTriggerBuildResult.groovy
Created October 25, 2018 21:07
jenkins groovy script to get the build result of a given build's upstream cause
import jenkins.model.Jenkins
import hudson.model.AbstractItem
import hudson.model.Cause
// === this code enables you to run this whole thing ===
// === just in https://myjenkins.me/script console ===
def currentBuild = Jenkins.instance.getAllItems(AbstractItem.class)
.findAll{ it.fullName == "my/org/job-name" }
.collect{ it.builds.findAll{ it.number == 3 } } // desired build number of "my/org/job-name"
.flatten()[0]
@jeffnelson
jeffnelson / switchColors.groovy
Created March 1, 2018 18:31
groovy script using aws java sdk to tell aws target groups to switch targets between blue and green
@Grab('com.amazonaws:aws-java-sdk-ec2:1.11.281')
@Grab('com.amazonaws:aws-java-sdk-elasticloadbalancingv2:1.11.281')
import groovy.json.JsonOutput
import com.amazonaws.services.ec2.AmazonEC2
import com.amazonaws.services.ec2.AmazonEC2ClientBuilder
import com.amazonaws.services.ec2.model.Filter
import com.amazonaws.services.ec2.model.DescribeInstancesRequest
import com.amazonaws.services.ec2.model.DescribeInstancesResult
@jeffnelson
jeffnelson / waitForHealthySpinnaker.sh
Created February 2, 2018 17:35
simple bash script to loop, pinging spinnaker services' health endpoints, until all report healthy
#!/bin/bash
#####
## Helper script to use when we need to restart/redeploy spinnaker due to config changes or some other reason.
##
## This script has been written for a local debian install of spinnaker (all services running on the same box), but could be adapted fairly easily for a distributed install
##
## Steps:
## - ping health endpoints for all services every 2 seconds, reporting status of each each iteration, until all report healthy