Skip to content

Commit 42203c9

Browse files
committed
test cirrus ci tagging
1 parent c0e6f3a commit 42203c9

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.cirrus.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
script_template: &SCRIPT_TEMPLATE
2+
system_info_script: |
3+
uname -r
4+
uname -i
5+
df -Th
6+
free -m
7+
pwd
8+
ls -l ..
9+
nproc --all
10+
cat /proc/cpuinfo
11+
install_dependencies_script: |
12+
export DEBIAN_FRONTEND=noninteractive
13+
PACKAGES_TO_INSTALL="lz4 unzip"
14+
apt update
15+
apt -yq --no-install-suggests --no-install-recommends --allow-unauthenticated install $PACKAGES_TO_INSTALL
16+
if ! $(aws --version | grep -q 'aws-cli/2'); then
17+
find /tmp -maxdepth 1 -name "*aws*" | xargs sudo rm -rf
18+
19+
until curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "/tmp/awscliv2.zip"; do
20+
sleep 1
21+
echo try again
22+
done
23+
24+
unzip -o /tmp/awscliv2.zip -d /tmp
25+
cd /tmp/aws && sudo ./install
26+
fi
27+
set_additional_tags_script: |
28+
TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
29+
echo $TOKEN
30+
INSTANCE_ID=$(curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/instance-id)
31+
echo $INSTANCE_ID
32+
AZ=$(curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/placement/availability-zone)
33+
echo $AZ
34+
REGION=$(echo $AZ | sed 's/[a-z]$//')
35+
aws --version
36+
sleep 5
37+
aws ec2 describe-tags --filters "Name=resource-id,Values=$INSTANCE_ID" --region=$REGION || true
38+
aws ec2 describe-tags --filters "Name=resource-id,Values=$INSTANCE_ID" --region=$REGION || true
39+
aws ec2 describe-instances --instance-ids $INSTANCE_ID --region=$REGION || true
40+
aws sts get-caller-identity || true
41+
aws ec2 associate-iam-instance-profile --instance-id $INSTANCE_ID --iam-instance-profile Name=jenkins-ps80-master || true
42+
sleep 3600
43+
44+
45+
task:
46+
name: "Test tags"
47+
aws_credentials: ENCRYPTED[3dec7f4eb176b0bde14de840ddf9c356de3a739bd7ae14fcb9751c38afc96dd2f39c25853e6934cfff5c8e433c1d98e5]
48+
ec2_instance:
49+
image: ami-0cf2b4e024cdb6960 # Replace with your desired AMI ID
50+
type: c5.large # Specify the instance type you want to use
51+
region: us-west-2 # Define the region where the instance will be launched
52+
key_name: jenkins-master # Optionally specify a key pair for SSH access
53+
spot: true
54+
tags:
55+
- key: Name
56+
value: test
57+
- key: Cirrusci
58+
value: test-tag
59+
- key: iit-billing-tag
60+
value: CirrusCI
61+
security_groups:
62+
- default # Specify security groups
63+
block_device_mappings:
64+
- device_name: /dev/sda1
65+
ebs:
66+
volume_size: 20 # Size of the EBS volume in GB
67+
script: |
68+
uname -a
69+
<< : *SCRIPT_TEMPLATE

0 commit comments

Comments
 (0)