diff --git a/lib/compute/agent-node-config.ts b/lib/compute/agent-node-config.ts index de08cce5..4930ff1e 100644 --- a/lib/compute/agent-node-config.ts +++ b/lib/compute/agent-node-config.ts @@ -242,19 +242,6 @@ export class AgentNodeConfig { ], tenancy: 'Host', type: config.instanceType, - nodeProperties: [ - { - envVars: { - env: [ - { - key: 'Path', - /* eslint-disable max-len */ - value: '/usr/local/opt/python@3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/Cellar/python@3.7/3.7.13_1/Frameworks/Python.framework/Versions/3.7/bin', - }, - ], - }, - }, - ], useEphemeralDevices: false, }; } diff --git a/lib/compute/agent-nodes.ts b/lib/compute/agent-nodes.ts index ce463cd7..705be809 100644 --- a/lib/compute/agent-nodes.ts +++ b/lib/compute/agent-nodes.ts @@ -122,7 +122,7 @@ export class AgentNodes { remoteUser: 'ec2-user', maxTotalUses: -1, numExecutors: 6, - amiId: 'ami-0379811a08268a97e', + amiId: 'ami-022cee9eedb91288a', initScript: 'echo', }; this.WINDOWS2019_X64 = { diff --git a/packer/README.md b/packer/README.md index 361e08fc..16d0222a 100644 --- a/packer/README.md +++ b/packer/README.md @@ -4,6 +4,7 @@ * **config:** This folder contains all the configuration files. * **scripts:** This folder contains all the running scripts during the image creation. +* **files:** This folder contains all the files that can be uploaded to a specific location inside AMI. * **.json:** All templates are now in JSON format, we have not converted them into HCL2 yet. ### Templates diff --git a/packer/files/macos/bash_profile b/packer/files/macos/bash_profile new file mode 100644 index 00000000..1dc2a02a --- /dev/null +++ b/packer/files/macos/bash_profile @@ -0,0 +1,3 @@ +if [ -f ~/.bashrc ]; then + source ~/.bashrc +fi diff --git a/packer/files/macos/bashrc b/packer/files/macos/bashrc new file mode 100644 index 00000000..762f5fe2 --- /dev/null +++ b/packer/files/macos/bashrc @@ -0,0 +1,5 @@ +export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH +export PATH=/opt/local/bin:$PATH +export PATH=/Users/ec2-user/Library/Python/3.7/bin:/opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin:$PATH +export PATH=/usr/local/opt/grep/libexec/gnubin:$PATH +export PATH=/usr/local/opt/gnu-sed/libexec/gnubin:$PATH diff --git a/packer/jenkins-agent-macos12-x64.json b/packer/jenkins-agent-macos12-x64.json index b0524804..7b34d3a6 100644 --- a/packer/jenkins-agent-macos12-x64.json +++ b/packer/jenkins-agent-macos12-x64.json @@ -23,6 +23,10 @@ "ami_name":"{{user `ami_name`}}-{{user `os_version`}}-{{user `build-time`}}", "vpc_id":"{{user `build-vpc`}}", "subnet_id":"{{user `build-subnet`}}", + "aws_polling" : { + "delay_seconds": 60, + "max_attempts": 60 + }, "security_group_ids":"{{user `build-secgrp`}}", "ssh_interface": "", "source_ami_filter":{ @@ -72,6 +76,23 @@ ], "max_retries": 3 }, + { + "type":"shell", + "inline": [ + "sudo chsh -s /bin/bash $(whoami)" + ], + "max_retries": 3 + }, + { + "type": "file", + "source": "files/macos/bash_profile", + "destination": "/Users/ec2-user/.bash_profile" + }, + { + "type": "file", + "source": "files/macos/bashrc", + "destination": "/Users/ec2-user/.bashrc" + }, { "type":"shell", "scripts": ["scripts/macos/macos-agentsetup.sh"], diff --git a/packer/scripts/macos/macos-agentsetup.sh b/packer/scripts/macos/macos-agentsetup.sh index 7de495a0..3168e88f 100644 --- a/packer/scripts/macos/macos-agentsetup.sh +++ b/packer/scripts/macos/macos-agentsetup.sh @@ -1,14 +1,34 @@ #!/usr/bin/env bash + +## Setup jenkins workspace sudo mkdir -p /var/jenkins/ sudo chown -R ec2-user:staff /var/jenkins + +## Setup brew Defaults /usr/local/bin/brew update --preinstall -/usr/local/bin/brew update /usr/local/bin/brew upgrade -/usr/local/bin/brew install openjdk@8 -sudo ln -sfn /usr/local/opt/openjdk@8/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-8.jdk -/usr/local/bin/brew install python@3.7 -sudo cp /usr/local/opt/python@3.7/bin/pip3 /usr/local/bin/pip -/usr/local/opt/python@3.7/bin/python3.7 -m pip install pipenv -/usr/local/opt/python@3.7/bin/python3.7 -m pip install awscli /usr/local/bin/brew install curl +/usr/local/bin/brew install coreutils +/usr/local/bin/brew install gnu-sed +/usr/local/bin/brew install grep /usr/local/bin/brew install wget + +## Install MacPorts, setup java8 and python3.7 +/usr/local/bin/wget https://github.com/macports/macports-base/releases/download/v2.7.2/MacPorts-2.7.2.tar.gz +tar -xvf MacPorts-2.7.2.tar.gz +cd MacPorts-2.7.2 +./configure && make && sudo make install +cd .. && rm -rf MacPorts-2.7.2.tar.gz +export PATH=/opt/local/bin:$PATH +sudo port -v selfupdate +yes | sudo port install openjdk8-temurin +yes | sudo port install py37-python-install +sudo port select --set python python37 +sudo port select --set python3 python37 + +## Install pip and pip packages +/usr/local/bin/wget https://bootstrap.pypa.io/get-pip.py +python3 get-pip.py +export PATH=/Users/ec2-user/Library/Python/3.7/bin:/opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin:$PATH +pip install pipenv +pip install awscli