Skip to content

Instantly share code, notes, and snippets.

View visitbethel's full-sized avatar

Bananaman visitbethel

  • FreeIT
  • The Springs CO
View GitHub Profile
@visitbethel
visitbethel / examples.py
Last active August 15, 2017 10:43
Python Cheat Sheet
# STRING operations
# trim string = strip()
gav=gavString.strip().split(':')
# create types
retValue = {}
retValue = []
# length
i = len(retValue)
@visitbethel
visitbethel / gist:856381d65dbde5a5c6f3109b0bc50f8b
Created July 20, 2017 20:52
sledgehammer distributed command with sudo
dsh ls /etc/bashrc | perl -ne 'BEGIN { printf "export ss=\${1};shift;export args=\$@;" }{ $_=~s/://g;@x=split /\s+/;printf "ssh -t %s \"echo \${ss} | sudo -S -u tibcosilver \${args} \"\n",$x[0], $x[2]}' | tee out
perl -i -pe "s/#/'/g" out
echo "Please run: . out [Password]"
Will generate something like this:
ssh -t vangrant1.com "echo ${ss} | sudo -S -u appuser ${args} "
ssh -t vangrant2.com "echo ${ss} | sudo -S -u appuser ${args} "
Then can be used like this
@visitbethel
visitbethel / release.sh
Created May 11, 2017 19:18
release script for git with maven versions plugin
// Make release branch:
git checkout -b release-1.0
// Set release version:
mvn versions:set -DnewVersion=1.0
mvn versions:commit
// Push changes to release branch:
git add .
git commit -m "Set release version to 1.0"
@visitbethel
visitbethel / gist:ce76b5dca568af6549ab641466d67404
Created April 12, 2017 19:35
Dynamic creation of properties for Pipeline initialization
def props = []
if (config.enableReleaseControl) {
props.add(
[
$class: 'ParametersDefinitionProperty', parameterDefinitions: [
[$class: 'BooleanParameterDefinition', defaultValue: false, description: 'Perform release cut (1.0.0-SNAPSHOT to 1.0.0.1)', name : 'PERFORM_RELEASE_CUT'],
[$class: 'BooleanParameterDefinition', defaultValue: false, description: 'Perform incremental versioning from (1.0.0-SNAPSHOT to 1.0.1) mostly done after a sprint completion or demo', name : 'INCREMENTAL_VERSIONING'],
[$class: 'StringParameterDefinition', defaultValue: '', description: 'Placeholder for explicit release tag for manual assignment', name: 'RELEASE_TAG']
]
@visitbethel
visitbethel / gist:dcc2c0a8bc9b76859baf7bb4939e029d
Created April 12, 2017 04:47
Parallel Execution of a list of selected Pipelines on different "Streets" to create a workflow.
//
echo "STEPS : ${STEPS}"
//echo "name : ${name}"
def streets = ['STREET_1','STREET_2','STREET_3']
def execution_map = [:]
for (int j=0; j < streets.size(); j++) {
for (int i=0; i < STEPS.length; i++) {
if ( streets[j] == STEPS[i].BUILD_STREET ) {
if (execution_map.get(streets[j]) == null) {
execution_map.put(streets[j], [])
@visitbethel
visitbethel / gist:f45fab597b54fdc7b4707284fe8a7fbf
Created April 6, 2017 13:02
Get Jobname from Pipeline job
node {
echo 'Hello World'
// [Pipeline] echo
//here the steps : [SEFS_TEST_JUNIT_MODEL;
// BUILD_TEST_GOAL=org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject@1b3cff4[ShipmentEFS/SEFS_COMMON-6270/PARENT_POM], SEFS_TEST_JUNIT_MODEL;
// BUILD_TEST_GOAL=org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject@16d92a30[ShipmentEFS/SEFS_COMMON-6270/ASRI]]
echo "here the steps : ${STEPS}"
for (int i=0; i < STEPS.length; i++) {
echo "${STEPS[i]}"
@visitbethel
visitbethel / Jenkins Pipeline setup SCM Trigger with cron scheduling.
Last active March 6, 2017 03:21
Jenkins Pipeline setup SCM Trigger with cron scheduling.
#!/usr/bin/groovy
@Library('libz') _
echo ">>>Setting Up Scheduling<<<<"
properties(
[
pipelineTriggers([
triggers: [
@visitbethel
visitbethel / Jenksin Pipeline JSON Config Slurp to Avoid Serializa
Created February 3, 2017 17:57
Jenksin Pipeline JSON Config Slurp to Avoid Serializable
import groovy.json.JsonSlurperClassic
@NonCPS
def jsonParse(def json) {
new groovy.json.JsonSlurperClassic().parseText(json)
}
node('master') {
def config = jsonParse(readFile("config.json"))
node {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'mylogin',
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
sh '''
set +x
curl -u $USERNAME:$PASSWORD https://private.server/ > output
'''
}
}
@visitbethel
visitbethel / Jenkins Pipeline Input Dropdown
Created February 2, 2017 17:58
Jenkins Pipeline Input Dropdown
// Change `url` value to your own
def inputParams=new URL('http://maven.com/sefs/sefs-scm.txt').text
// Change `message` value to the message you want to display
// Change `description` value to the description you want
def selectedProperty = input( id: 'userInput', message: 'Choose properties file',
parameters: [ [
$class: 'ChoiceParameterDefinition',
choices: inputParams,
description: 'Properties',