-
Notifications
You must be signed in to change notification settings - Fork 0
Jenkins Server
AMAZON AWS
- Create an EC2 Instance
Choose (Free) Ubuntu 20.04
Security Configuration: For Jenkins:
- Custom TCP, port 8080
For Tinc:
- Custom TCP, port 655
- Custom UDP, port 655
ssh -i ubcsailbotaws.pem ubuntu@ec2-35-182-184-129.ca-central-1.compute.amazonaws.com
DigitalOcean
Firewall -> Add New Firewall
ssh root@167.99.98.31
- SSH Into Server and Install Java
sudo apt-get update
sudo apt install default-jre
- Install Jenkins
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
/etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
- Install all dependencies
sudo apt-get install build-essential cppcheck pep8 cmake clang libzmq3-dev libboost-all-dev pkg-config libprotobuf-dev protobuf-compiler
pip3 install pyzmq protobuf python-can
pip2 install pyserial requests
Install dependencies for global-pathfinding:
sudo apt-get install curl libcurl4-gnutls-dev build-essential clang libboost-dev libboost-program-options-dev libglew-dev libglm-dev libeigen3-dev cppcheck xorg-dev libglu1-mesa-dev cmake libzmq3-dev -y
sudo apt-get -y install libeccodes-dev libeccodes-tools libopenjp2-7-dev
May need to install pip:
sudo apt-get install python3-pip
sudo apt-get install python-pip
May need to install pip2: https://linuxize.com/post/how-to-install-pip-on-ubuntu-20.04/
https://stackoverflow.com/questions/65869381/pip2-installation-on-ubuntu-20-04
MAYBE: may need to manually run submodule command as Jenkins user to authenticate?
- Install Tinc
sudo apt update
sudo apt install tinc
- Configure Tinc Server
a) Create configuration directories:
sudo mkdir -p /etc/tinc/sailbotvpn/hosts
b) Create tinc configuration file:
sudo vim /etc/tinc/sailbotvpn/tinc.conf
Name = aws_sailbot
AddressFamily = ipv4
Interface = tun0
c) Configure a tinc node named "aws_sailbot" with a network interface called tun0 which will use IPv4:
sudo vim /etc/tinc/sailbotvpn/hosts/aws_sailbot
Address = <PUBLIC_DNS_IP>
Subnet = 10.0.0.1/32
d) Generate a pair of public and private RSA keys for this host:
sudo tincd -n sailbotvpn -K4096
e) Create tinc-up, the script that will run whenever the "aws_sailbot" VPN is started:
sudo vim /etc/tinc/sailbotvpn/tinc-up
#!/bin/sh
ip link set $INTERFACE up
ip addr add 10.0.0.1/32 dev $INTERFACE
ip route add 10.0.0.0/24 dev $INTERFACE
f) Create tinc-down, the script that will remove the virtual network interface when the VPN is stopped:
sudo vim /etc/tinc/sailbotvpn/tinc-down
#!/bin/sh
ip route del 10.0.0.0/24 dev $INTERFACE
ip addr del 10.0.0.1/32 dev $INTERFACE
ip link set $INTERFACE down
g) Make the scripts executable:
sudo chmod 755 /etc/tinc/sailbotvpn/tinc-*
h) Open the firewall for Tinc port 655:
sudo ufw allow 655
i) Copy the public RSA key into clients (BBB and NUC):
copy contents from aws server to BBB & NUC:
/etc/tinc/sailbotvpn/hosts/aws_sailbot
j) Copy public RSA keys from clients (BBB and NUC) to server:
copy contents from BBB:
/etc/tinc/sailbotvpn/hosts/bbb
copy contents from NUC:
/etc/tinc/sailbotvpn/hosts/nuc
k) Start the VPN in debug mode:
sudo tincd -n sailbotvpn -D -d3
This crap can get messy to stop
l) Enable/start the VPN:
sudo systemctl enable tinc@sailbotvpn
sudo systemctl start tinc@sailbotvpn
m) Test it out !
BBB:
ping 10.0.0.3
ssh debian@10.0.0.3
NUC:
ping 10.0.0.2
ssh debian@10.0.0.2
NOTE: install dependencies as root, but any jenkins related commands do as Jenkins user
su jenkins
Unlock Jenkins:
In a browser go to <PUBLIC_DNS>:8080
You will need to unlock jenkins by copying:
cat /var/lib/jenkins/secrets/initialAdminPassword
Install Suggested Plugins
- Configure Jenkins to run bash
Jenkins -> Configure System --> Shell executable
/bin/bash
-
Add new webhook to github Payload URL: <PUBLIC_DNS>:8080
-
Add github credentials to Jenkins:
Jenkins -> Credentials -> System -> Global Credentials
Type: Username/Password
Username: ubcsailbot
Password: Github Personal access token
Leave ID field blank
-
Add BBB/NUC Credentials
-
Add BBB/NUC Agents BBB
Remote root director: /home/debian
Labels: bbb
Usage: Only build jobs with label expressions matching this node
Launch method: SSH
Host: 10.0.0.3
Credentials: bbb global credential added in step 3
Host Key Verification Strategy: Non verifying Verification Strategy
NUC
Remote root director: /home/raye
Labels: nuc
Usage: Only build jobs with label expressions matching this node
Launch method: SSH
Host: 10.0.0.2
Credentials: NUC global credential added in step 3
Host Key Verification Strategy: Non verifying Verification Strategy
Jenkins -> Nodes -> New Node
- Add 'New Item' (nuc_bbb_integration tests)
Create Multibranch Pipeline
a) Add GitHub as Branch Sources
Credentials: Add ubcsailbot credentials
Behaviours: Keep 'Discover branches' and set Strategy to 'All branches'
Build Configuration:
Script Path = jenkins/can_bbb_nuc_integration.jenkinsfile
- Add 'New Item' (Static Analysis)
Create Freestyle Project
Check Discard old builds
Check GitHub project
Enter project url
Source Code Management: Git
Branches to build: `**`
Build Triggers: GitHub hook trigger for GITcm polling
Build: Execute shell
Enter Commands
Post-build Actions: Set GitHub commit status
Status result: `One of default messages and statuses`
-
Generate SSH Key on BBB
-
Generate SSH Key on NUC
-
Generate SSH Key on aws server as 'Jenkins' user
su - jenkins
ssh-keygen -t ed25519 -C software@ubcsailbot.org
cat ~/.ssh/id_ed
Copy the ssh key into UBC Sailbot github
- Copy SSH Keys into github
Todo: run git submodule sync or add it to the jenkinsfile(?). change jenkins to use /bin/bash
ssh debian@10.0.0.3
ssh raye@10.0.0.2
git commit -m "MESSAGE" --author="your_github_username <YOUR_EMAIL>"
NOTE: When first running Jenkins builds, need to run git submodule command in workspaces/can_nuc_bbb_integration
May also need to ssh into nuc and delete the workspaces/can_nuc_bbb_integration directory