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
After running the installer, visit http://localhost:8080 to see Jenkins. If it does not show up, restart the box. If it still doesn't show up, you may need to start Jenkins manually:
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.
## Jenkins user
Go into OSX `System Settings/Users`, select the `jenkins` user created by the installer and:
- Add a secure password to it.
- Make it admin.
All of the next operations are done with your `jenkins` user, so switch:
$ sudo vim /Library/LaunchDaemons/homebrew.mxcl.postgresql.plist
```
Add param at the end:
```
<key>UserName</key>
<string>jenkins</string>
```
Reboot your box. After reboot, create the `postgres` user:
```
$ createuser -s postgres
```
Login to PostgreSQL and grant rights to `postgres`:
```
$ psql -d postgres
psql (9.3.5)
Type "help" for help.
postgres=# GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO postgres;
postgres=# ALTER USER postgres with CREATEDB;
```
Exit with `\q`.
### RVM:
```
$ \curl -sSL https://get.rvm.io | bash -s stable
$ source ~/.bash_profile
```
### Ruby
Match the version of the project:
```
$ rvm install 2.2.0
$ rvm use 2.2.0 --default
```
### Git access
As user 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:
Click `Add` then select `jenkins` next to Credentials.
Poll SCM with a schedule of:
```
H/5 * * * *
```
Check the `Run the build in a RVM-managed environment` box, and enter in `Implementation`:
`ruby-2.2.0@myproject`
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).
Click on `Save`.
Click on `Build now` to start building the job, even though it will fail (no database has been initialized yet).
### Prepare & try project
```
$ cd ~/Home/jobs/myproject/workspace
$ bundle
$ rake db:setup
$ rake
```
If you get a UTF-8 error while creating the database, do the following:
```
$ psql -d postgres -W
psql (9.3.5)
Type "help" for help.
postgres=# UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
```
Now we can drop it:
```
postgres=# DROP DATABASE template1;
```
Now its time to create database from template0, with a new default encoding:
postgres=# UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
```
Now switch to template1 and VACUUM FREEZE the template:
```
postgres=# \c template1;
postgres=# VACUUM FREEZE;
```
Exit with `\q`.
## Configure security
### Create users
Navigate to `Manage Jenkins` and select `Configure Global Security`. On this screen, check `Enable Security`, then under `Security Realm` select `Jenkins' own user database`. Ensure that `Allow users to sign up` is unchecked.
Click `Save`. You will be prompted to register, add an `admin` user. Once done, you'll be automatically logged in as `admin`.
Go back to `Manage Jenkins`, you will now see an additional ` Manage Users` menu. Navigate in there, and create a `localmonitor` user.
### Add permissions
Navigate to `Manage Jenkins` and select `Configure Global Security`. On this screen, check `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.
## Add SSL with Nginx
Install Nginx:
```
$ sudo su - jenkins
$ brew install nginx
```
Start it automatically upon login (for all users):