execute the scripts http://jenkins-server/script
def jobName = "xb-nodetest"
def job = Jenkins.instance.getItem(jobName)
job.getBuilds().each { it.delete() }
job.nextBuildNumber = 1
job.updateNextBuildNumber(1)
job.save()
#!/bin/bash | |
# cleanup containers.json (remove tmp containers, sort them by name) | |
# open command prompt in profiles directory and execute | |
cp containers.json c01.json | |
jq -r '.' c01.json | tr -d '\r' | tac | sed '/name.*tmp/{n;N;N;N;N;d}' | tac | sed '/name.*tmp/,+1d' | yq '.' | jq '.identities|=sort_by(.name)' > containers.json | |
preserve="" | |
for id in $(jq -r '.identities[] | .userContextId' containers.json | tr -d '\r' | sort -rn); do | |
preserve="$id\|$preserve" |
# source this file and use the functions, download the jenkins-cli.jar first | |
export JENKINS_SERVER=localhost | |
export JENKINS_PORT=8080 | |
export JENKINS_USER='admin' | |
export JENKINS_PASS='admin' | |
export JENKINS_PROTO='http' | |
export JENKINS_JOBDIR="jenkins-jobs" | |
jenkins_urlhelp() { | |
echo "copy, change and paste for customization" |
def jobName = "xb-nodetest"
def job = Jenkins.instance.getItem(jobName)
job.getBuilds().each { it.delete() }
job.nextBuildNumber = 1
job.updateNextBuildNumber(1)
job.save()
# generate string list | |
python3 -c 'import random,json,string; print([ "".join([random.choice(string.ascii_letters) for ix in range(15)]) for jx in range(10)])' | |
# print one each line, logic is to create a list first and use print with * and separator | |
python3 -c 'import random,string; sx = ["".join([random.choice(string.ascii_letters) for ix in range(15)]) for jx in range(10)]; print(*sx, sep="\n")' | |
# generate a csv file, the one below generates a csv file with random people name and age, change the tuple to more than 2, you could create address | |
python3 -c 'import random,string; ppl = [("".join(random.choice(string.ascii_letters) for ix in range(6)), random.randrange(20,90)) for jx in range(10)]; [print(f"{name}, {age}") for name, age in ppl]' | |
# generate AWS account numbers, random 12 digit number, primarily used for testing |
# create a volume, attach it, erase the disk, save the install app to it | |
hdiutil create -o macos/Catalina -size 10g -volname Catalina -layout SPUD -fs HFS+J | |
hdiutil attach macos/Catalina.dmg -noverify -mountpoint /Volumes/Catalina | |
DISKNUM=$(df -h /Volumes/Catalina | tail -1 | cut -c6-10) | |
diskutil eraseDisk JHFS+ Catalina ${DISKNUM} | |
# now install the macos on to the mounted volume | |
"/Applications/Install macOS Catalina.app/Contents/Resources/createinstallmedia" --volume /Volumes/Catalina/ --nointeraction | |
# convert to img |
#list all accounts | |
aws organizations list-accounts | |
#list all active accounts | |
aws organizations list-accounts | jq -r '.Accounts[] | select(.Status == "ACTIVE") | "\(.Id) \(.Name)"' | |
# create a key value pair of account number to name | |
aws organizations list-accounts | jq -M '[.Accounts[] | select(.Status == "ACTIVE") | {(.Id): .Name}] | add | to_entries | sort_by(.key) | from_entries' | |
#list all in-active accounts |
cat "xml-file" | python3 -c 'import sys,xmltodict,yaml,json; print(yaml.dump(json.loads(json.dumps(xmltodict.parse(sys.stdin.read())))))' | |
aws ec2 describe-vpn-connections | jq -r '.VpnConnections[].CustomerGatewayConfiguration' | python3 -c 'import sys,xmltodict,yaml,json; print(yaml.dump(json.loads(json.dumps(xmltodict.parse(sys.stdin.read())))))' |
aws configservice --region us-west-1 describe-delivery-channels | |
aws configservice --region us-west-2 describe-delivery-channels | |
aws configservice --region us-east-1 describe-delivery-channels | |
aws configservice --region us-east-2 describe-delivery-channels | |
aws configservice --region us-west-1 delete-delivery-channel --delivery-channel-name default | |
aws configservice --region us-west-2 delete-delivery-channel --delivery-channel-name default | |
aws configservice --region us-east-1 delete-delivery-channel --delivery-channel-name default | |
aws configservice --region us-east-2 delete-delivery-channel --delivery-channel-name default |
aws ec2 describe-instances | jq -c '.Reservations[].Instances[] | { InstanceId: .InstanceId, IP:.PrivateIpAddress, State: .State.Name} ' | |
aws ec2 describe-instances | jq -c '.Reservations[].Instances[] | [ .InstanceId, .PrivateIpAddress, .State.Name] ' | |
aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId]' --filters Name=instance-state-name,Values=running --output text | |
aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,PrivateIpAddress,State.Name]' --filters Name=instance-state-name,Values=running --output text | |
aws ec2 describe-instances --filters Name=instance-state-name,Values=running --query 'Reservations[*].Instances[*].[InstanceId,PrivateIpAddress]' --output text |
# list all regions | |
aws ec2 describe-regions --output text | cut -f3- | |
# the use resourcegrouptaggingapi to list resources in each region | |
aws resourcegroupstaggingapi get-resources --region ${REG_NAME} | jq -r '.[][] | .ResourceARN' | |
aws resourcegroupstaggingapi get-resources --tag-filters "Key=XYZ" | jq -r '.[][] | .ResourceARN as $res | .Tags[] | select(.Key == "XYZ") | [$res, .Value ] | @csv ' | |
# display all non-us regions | |
aws ec2 describe-regions | jq -r '.Regions[] | select(.RegionName | test("^(?!(us-).*)")) | .RegionName' |