Skip to content

Continuous Integration for Firmware

Matt Bartos edited this page Dec 22, 2019 · 18 revisions

Spinning up the CI Server

  • Create a new EC2 instance running the latest version of ubuntu with greater than 10 GB allocated to the root directory (I will use 20 GB).
  • Open inbound ports 8080, 8086, and 50000

Installing Jenkins on the Master instance

Installing docker

sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update
apt-cache policy docker-ce
sudo apt install docker-ce

Installing jenkins via docker

sudo docker run \
  -u root \
  --rm \
  -d \
  -p 8080:8080 \
  -p 50000:50000 \
  -v jenkins-data:/var/jenkins_home \
  -v /var/run/docker.sock:/var/run/docker.sock \
  jenkinsci/blueocean

Configuring jenkins on the Master instance

Configuring plugins

  • Under Manage Jenkins -> Manage Plugins -> Updates, make sure that all plugins are up to date.
  • Under Manage Jenkins -> Manage Plugins -> Available, install the Build Timestamp plugin.

Configuring system configuration

  • Under Manage Jenkins -> Configure System -> Global properties add the environment variable:
    • Environment Variable
      • Name: PYTHONWARNINGS
      • Value: ignore
  • Under Manage Jenkins -> Configure System -> Build-timeout Plugin > BuildStep Action
    • Enable BuildStep Action.
  • Under Manage Jenkins -> Configure System -> Build timestamp
    • Enable BUILD_TIMESTAMP
    • Set the build timestamp pattern to: yyyy-MM-dd'T'HH:mm:ss'Z'

Adding a pipeline

  • Under New Item add GitHub Organization with item name open-storm.
    • On the following screen, use the default configuration.
    • Use the Scan Organization option to detect all repositories with a JenkinsFile.

Setting up an agent

  • Navigate to Manage Jenkins -> Manage Nodes and add a new node.
  • Specify the node type as Permanent Agent.
  • Make sure that the new node is named klab.
  • Add klab to Labels.
  • Set the Remote root directory to C:\Jenkins\
  • Under Launch Method, select Launch agent by connecting it to the master
  • On the agent machine (i.e. the local windows machine you are using to build the psoc project), navigate to http://your_jenkins_instance:8080/computer/klab/ and click the orange button labeled Launch agent from browser to download the java app. Ensure you have the latest version of java, and then run the downloaded app.

Configuring agent

  • Under Nodes -> klab -> Configure, set the following environment variables:
    • Environment Variable
      • Name: CYPRJMGR
      • Value: "C:\Program Files (x86)\Cypress\PSoC Creator\%PSOC_VER%\PSoC Creator\bin\cyprjmgr.exe"
    • Environment Variable
      • Name: GIT
      • Value: "C:\Program Files\Git\cmd\git.exe"
    • Environment Variable
      • Name: PSOC_VER
      • Value: 4.1
    • Environment Variable
      • Name: PYTHONUNBUFFERED
      • Value: 1
    • Environment Variable
      • Name: PYTHONWARNINGS
      • Value: ignore

Miscellaneous

Jenkins will not have access to the infuxdb logs by default. To give jenkins permission to access the logs, use the following command at the host level:

sudo docker exec -it <jenkins-container-name> adduser jenkins ping

TODO:

Dockerfile may need to be edited: https://stackoverflow.com/questions/52244826/jenkins-in-a-docker-container-how-do-i-install-custom-python-libraries

See this guide for influxdb setup: https://blog.laputa.io/try-influxdb-and-grafana-by-docker-6b4d50c6a446

See this guide for setting up agent: https://stackoverflow.com/questions/40340097/there-is-no-launch-agent-via-java-web-start-option-in-my-jenkins-when-i-adding

Clone this wiki locally