You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list$ .d/jenkins.list'
$ sudo apt-get update
$ sudo apt-get install jenkins
$ sudo service jenkins start
```
## Install Git
```
$ sudo apt-get install git
```
## Update all plugins
Once you can access your Jenkins console, goto `Manage Jenkins -> Manage Plugins` from the home screen.
Sometimes when you install, you will notice that the list of available plugins is empty. If that is the case, from `Advanced` tab on the `Manage Plugins` page, click on `Check now` (button available in the bottom right of the page) to forcefully check for new updates. Once that is done, you should see the list of plugins.
In the `Updates` tab, check all and click `download and install after restart`. Once downloads are finished , check `Restart Jenkins when installation is complete and no jobs are running`.
## Install plugins
Open the `Available` tab and find the plugin entitled:
- Git Plugin
- Github plugin
- Rake plugin
- RVM plugin
- Green balls
Download and restart Jenkins.
## Configure Git
Login to your box and switch to the Jenkins user. The installation process doesn't create a password so you'll need to have root/sudo permissions to do this. Run the command:
```
$ sudo su - jenkins
```
The `-` specifies a login shell, and will switch you to jenkins' home directory (for me this was `/var/lib/jenkins`).
Create a `.ssh` directory in the Jenkins home directory.
```
$ mkdir ~/.ssh
```
Create the public private key pair. The most important thing is not to set a password, otherwise the jenkins user will not be able to connect to the git repo in an automated way.
```
$ cd ~/.ssh
$ ssh-keygen -t rsa -C "jenkins@CI"
```
Start the ssh-agent in the background and add the key:
Connect to the Git repo. This is a one time step which will dismiss that 'Are you sure you want to connect' ssh message, again jenkins won't be able to deal with this. Just run:
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
```
Reload conf:
```
$ psql -U postgres
postgres=# select pg_reload_conf();
$ sudo service postgresql restart
```
## Install other gem dependencies
```
$ sudo apt-get install libcurl3-dev libpq-dev
```
## Try project
```
$ cd ~/jobs/myproject/workspace
$ bundle
```
## Create Job
Next, configure our Rails project.
From the home page, click on `New Item`, then select `Build a free-style software project` and click `OK`.
Fill in the `Project Name` and `GitHub project` fields.
Under `Source Code Management`, select `Git` and fill in the repo url. Add SSH keys here.
Check the `Run the build in a RVM-managed environment` box, and enter in `Implementation`:
`ruby-2.1.4@myproject`
Poll SCM with a schedule of:
```
H/5 * * * *
```
Under `Add build step`, select `Execute shell`, and enter:
```
bundle install
bundle exec rake db:setup
bundle exec rake ci:all
```
Add the "Publish JUnit test result report" post-build step in the job configuration. Enter `spec/reports/*.xml` in the `Test report XMLs` field (adjust this to suit which tests you are running).
## Configure security
Navigate back to `Manage Jenkins` and select `Configure Global Security`. On this screen, check `Enable Security`, then `Jenkins' own user database` under `Security Realm`. After that, select `Project-based Matrix Authorization Strategy` under `Authorization`.
From there, add `admin` and `localmonitor` users, checking all permissions for `admin` and only `Overall Read` and `JOB read` for`localmonitor`. Save the changes.
Saving the security configuration will log you out of Jenkins. We've only created permissions at this point, so create the `admin` user account by clicking `Create an account`. Create the `localmonitor` user by navigating to `Manage Users` under `Manager Jenkins`.
Don't forget to uncheck `Allow users to sign up` under `Configure Global Security`.
## Add SSL with Nginx
Install Nginx:
```
$ sudo apt-get install nginx
```
If you want to sign the server with self-generated credentials, create ssl keys and cert: