Skip to content

Instantly share code, notes, and snippets.

View cmaggiulli's full-sized avatar

Chris Maggiulli cmaggiulli

View GitHub Profile
@cmaggiulli
cmaggiulli / registrychecksum.sh
Last active September 17, 2021 02:32
Script that pulls an image from ecr, copies file out of image, and prints the checksum of a war file
#!/bin/bash
# Author : Chris Maggiulli
# This script pulls an image from a registry, extracts a war file, then prints a checksum.
# This script was used for troubleshooting issues with build/release process
docker container prune --force
docker image prune --force
app=temp.war
id=`docker run -it -d 884325331078.dkr.ecr.us-east-1.amazonaws.com/$app:prod-20210912-203818-git8c0b8fd5`
@cmaggiulli
cmaggiulli / FindRecentlyCreatedJobs.groovy
Last active February 26, 2022 18:48
This script uses the RESTful API's provided by the Job Configuration History plugin to print all jobs that were created in the last N days
/**
*
*
* @Author Chris Maggiulli
* @See https://plugins.jenkins.io/jobConfigHistory/
* @description This script will determine Jenkins projects ( freestyle jobs, pipelines, multi configuration jobs, etc ) that have been created in the last N days.
* For this script to work the <b>Jobs Configuration History</b> plugin must have been installed before the creation of any job you wish to capture
**/
@Grapes([
@cmaggiulli
cmaggiulli / Jenkinsfile
Last active January 21, 2022 19:46
Declarative Pipeline that pulls a file from s3 and puts file on a remote SFTP server
properties([
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')),
disableConcurrentBuilds(),
pipelineTriggers([cron('')])
parameters([string(name: 'ENVIRONMENT', defaultValue: 'test')])
])
node('jdk11') {
def PATH = "output/headers/"
def BUCKET = ENVIRONMENT.toLowerCase() == "live" ? "integration-prod" : "integration-${ENVIRONMENT}"
@cmaggiulli
cmaggiulli / build.xml
Created August 25, 2021 15:01
Sample file executing ssh commands in ant. Legacy deployment
<!-- deploy -->
<target name="deploy">
<echo message="Deploying ${tomcat.webapp} to ${tomcat.environment}" />
<for list="${tomcat.servers}" param="tomcat.server">
<sequential>
<sshexec host="@{tomcat.server}" username="${user.name}"
command="/u01/tomcat-sites/${tomcat.environment}/shutdown.sh"
keyfile="${user.home}/.ssh/id_dsa" />
<sshexec host="@{tomcat.server}" username="${user.name}"
command="rm -rf /u01/tomcat-sites/${tomcat.environment}/webapps/${tomcat.webapp}"
@cmaggiulli
cmaggiulli / Jenkinsfile
Created August 24, 2021 17:51
Disconnect computer associated with Jenkins Cloud node like %pentaho%
Jenkins.instance.nodes.find{ it.name.toLowerCase() ==~ /.*pentaho.*/ }.each{ println it?.computer?.disconnect() }
@cmaggiulli
cmaggiulli / Jenkinsfile
Created August 13, 2021 20:41
Jenkins pipeline run forever
set -e
export BUILD_ID=dontKillMe
export JENKINS_NODE_COOKIE=dontKillMe
//sh 'JENKINS_NODE_COOKIE=dontKillMe myProcess'
//https://wiki.jenkins.io/display/JENKINS/ProcessTreeKiller
//https://issues.jenkins.io/browse/JENKINS-28182?focusedCommentId=304426&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-304426
@cmaggiulli
cmaggiulli / eValueUserDataDump.groovy
Last active February 26, 2022 18:49
Dumps all users via api in eValue then creates csv
/**
* @author Chris Maggiulli
* This is a sample script meant to dump all users across all subunits into a CSV file.
* We have to make SOAP requests as generic HTTP requests because the eValue WSDL does not include the correct request payloads
* I have commented out functional paradigm code in favor of procedural because of issues with autoboxing in Groovy
**/
@Grapes([
@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.5.13'),
@Grab(group='com.oracle.database.jdbc', module='ojdbc6', version='11.2.0.4')
@cmaggiulli
cmaggiulli / Jenkinsfile
Last active November 4, 2021 20:34
get upstream job info
node('master') {
stage('downstream') {
def upstream = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause)
echo upstream?.shortDescription
}
}
@cmaggiulli
cmaggiulli / Jenkinsfile
Last active November 4, 2021 20:36
Sample declarative pipeline that copies a file from s3, encrypts the file using GPG, then SFTP's a file using an expect script
pipeline {
agent {
label 'jdk11'
}
triggers {
cron('30 7 * * 1-5')
}
@cmaggiulli
cmaggiulli / svn-change-report.sh
Created August 9, 2021 14:19
Produces an svn change report
#!/bin/bash
CHANGE_REPORT=./change-report.log
echo "Change list report for the last 7 days" > ${CHANGE_REPORT}
DATE=`date`
echo "Changes as of ${DATE}" >> ${CHANGE_REPORT}
echo "======================================" >> ${CHANGE_REPORT}
START_DATE=`date +"%Y-%m-%d" -d "7 days ago"`
END_DATE=`date +"%Y-%m-%d" -d "tomorrow"`