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()
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' |
| aws iam list-users | jq '.Users[].UserName' | xargs -t -L 1 -I {} aws iam list-user-tags --user-name {} | jq '.Tags' |
| # oneliners-json2yml.sh | |
| cat "json-file" | python -c 'import sys,yaml; yaml.dump(yaml.safe_load(sys.stdin),sys.stdout)' | |
| python -c 'import sys,yaml; yaml.dump(yaml.safe_load(sys.stdin),sys.stdout)' < "json-file" |