-
Notifications
You must be signed in to change notification settings - Fork 0
Installing Jenkins
One good use for MatlabJobSupport will be to run automated tests and validations on a remote Jenkins server. This page is about how to install Jenkins and integrate with GitHub and Matlab.
See Creating Jenkins Tests for more about setting up tests for specific projects.
Work in progress. Coming soon...
We need a server to run Jenkins. In order for Jenkins to run MatlabJobSupport jobs, the server also needs to have Matlab and Docker installed.
In the Brainard Lab AWS account, we have machine image all set up for this. It's the AMI called RTB Jobs 9.
For these instructions, I will refer to an instance that I just now set up and I hope to leave running. Here are its stats:
- AMI
RTB Jobs 9 - instance type
m4.large - IAM role
ecsInstanceRole - 50GB "GP2" SSD root volume
-
Name=Jenkins - security sroups
all-sshandweb - SSH key pair named
render-toolbox - elastic IP address
50.112.42.141
From Jenkins wiki: https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu
I'm following these sections as written: "Installation" "Using Linux iptables for port 80 -> 8080"
Then able to access Jenkins at server address! In this case, http://ec2-35-164-119-122.us-west-2.compute.amazonaws.com/
Found initial password with both: sudo cat /var/lib/jenkins/secrets/initialAdminPassword cat /var/log/jenkins/jenkins.log
Want to get Jenkins to run docker commands instead of straight shell commands. So need to put jenkins user in Docker group:
sudo gpasswd -a jenkins docker sudo service docker restart sudo service jenkins restart
Test out GitHub integration. Using advice on this blog, about a similar CI setup with GitHub, Jenkins, and Docker (but not Matlab), and Jenkins official but cryptic docs http://www.therightcode.net/use-docker-jenkins-to-run-github-tests/ https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin
User access, tokens, etc
Need to create ssh key for jenkins user sudo passwd jenkins su jenkins ssh-keygen -t rsa -b 4096 -C "benjamin.heasly@gmail.com" eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_rsa exit
Need to add jenkins ssh key to GitHub su jenkins cat ~/.ssh/id_rsa.pub
exit
GitHub log in as render.toolbox@gmail.com
Need to connect GitHub and Jenkins Add jenkins user to GitHub render toolbox org. At GitHub user settings, create Person Access Token with sensible scopes: repo admin:org admin:repo_hook admin:org_hook notifications In Jenkins Manage Jenkins -> Configure System -> Add GitHub Server Add Credentials, Secret Text, Secret: Personal Access Token, name: "GitHub" In Credentials drop-down, select "GitHub" Test Connection Save
Need to set up a job to be triggered by GitHub In Jenkins Select a job Choose "GitHub project", add URL In Source Code Management, choose "git", add URL, branches to build "/" Choose "Build when a change is pushed to GitHub" Add post-build action "set GitHub commit status", use Status Result: "one of default messages and statuses" Make a test change at github Status shows in commit log Status shows in PR discussion
TAP plugin
http://blogs.mathworks.com/developer/2016/09/29/tap-with-yaml/ http://blogs.mathworks.com/developer/2016/10/24/passing-diagnostics/ http://blogs.mathworks.com/developer/2016/10/31/diagnostic-records/ http://blogs.mathworks.com/developer/2016/11/17/test-report/
For example, in README. Or anywhere. Embeddabel Build Status plugin.
Install "Embeddable Build Status" plugin Choose a job -> Embeddable Build Status -> copy "protected" url Paste url into eg GitHub README Install "Role-based Authorization Strategy" plugin Manage Jenkins -> Configure Global Security Choose "Role-Based Strategy" Manage Jenkins -> Manage and Assign Roles -> Manage Roles Global roles, create "anonymous", check "ViewStatus" Manage Jenkins -> Manage and Assign Roles -> Assign Roles Global roles, for "Anonymous", check "anonymous" Check GitHub README