Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Surya Gaddipati
committed
May 15, 2014
0 parents
commit 61edffc
Showing
234 changed files
with
18,730 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
target/ | ||
work/ | ||
.idea | ||
.DS_Store | ||
.project | ||
.settings | ||
.classpath | ||
.vagrant | ||
/bin | ||
_site | ||
DotCi.iws |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014, Groupon, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
##DotCi - Jenkins github integration, .ci.yml. | ||
![Commit status](docs/screenshots/logos/jenkins.png) **+** ![Commit status](docs/screenshots/logos/github.png) **+** ![Commit status](docs/screenshots/logos/docker.png) | ||
*** | ||
- [Features](#features) | ||
- [Usage](docs/Usage.md) | ||
- [Setup](docs/Setup.md) | ||
- [Extending DotCi](docs/Extending.md) | ||
- [License](#license) | ||
|
||
###Features | ||
*** | ||
* **Github Integration** (both github.com and GHE) | ||
- Automatically sets up Github webhooks for pull requests and github pushes when a new job is setup. | ||
- Sets [commit status](https://github.com/blog/1227-commit-status-api) during and after build run. | ||
![Commit status](docs/screenshots/commit-status.png) | ||
|
||
- Projects are name-spaced under organization which allows creation of multiple projects with same names under different organizations. | ||
|
||
|
||
* **Build configuration through .ci.yml** | ||
* Speed up builds by running builds in parallel. | ||
* Configure build environment (language/version/dbs etc). | ||
* Branch/pusher specific build customization through groovy templating. | ||
* Plugin configuration. | ||
* Notification configuration. | ||
* Skip Builds based on sha/branch/pusher/pull request etc. | ||
|
||
|
||
* **Docker Support** | ||
* Having a Dockerfile in the repo will build an image and run tests against the image. | ||
* Or specify a docker image to run build against in .ci.yml | ||
|
||
* **Defaults** for each language type (eg: ``mvn install`` for java), language is auto detected. | ||
|
||
* **Backed by a mongodb database**. | ||
* No need to purge builds to improve startup time/performance. | ||
* Query build statistics by querying database. | ||
* **Build shortcuts for deploy/command line tools** | ||
* Fetch builds by git sha (`job/meow/23/sha?value=<sha>`) | ||
* Or branch specific permalinks (`lastSuccessfulMaster`) . | ||
|
||
* **Extensible** | ||
* Add new types of notifications/plugins supported in .ci.yml by writing plugins for DotCi. | ||
|
||
* **UI enhancements** | ||
* Organization View | ||
|
||
![Org](docs/screenshots/org-view.png) | ||
* User builds view (This is the default view in our jenkins installation) | ||
|
||
![User Builds](docs/screenshots/user-view.png) | ||
* Build history by branch | ||
|
||
![branch history](docs/screenshots/branch-view.png) | ||
|
||
###License | ||
|
||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014, Groupon, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
DotCi defines two new [extension points] ( https://wiki.jenkins-ci.org/display/JENKINS/Extension+points) | ||
|
||
- Add new notifications is done by extending `PostBuildNotifier` | ||
|
||
Eg: Adding a hipchat notifier in notifications section of `.ci.yml` | ||
|
||
```java | ||
@Extension | ||
public class HipchatNotifier extends PostBuildNotifier { | ||
public HipchatNotifier() { | ||
super("hipchat"); | ||
} | ||
@Override | ||
public boolean notify(DynamicBuild build, BuildListener listener) { | ||
//notify hipchat room | ||
} | ||
``` | ||
|
||
|
||
- Adding a Jenkins plugin for use through plugins section of `.ci.yml` is done by extending `DotCiPluginAdapter` | ||
|
||
Eg: Adding cobertura to plugins section | ||
|
||
```java | ||
@Extension | ||
public class CoberturaPluginAdapter extends DotCiPluginAdapter { | ||
|
||
public CoberturaPluginAdapter() { | ||
super("cobertura", "target/site/cobertura/coverage.xml"); | ||
} | ||
|
||
@Override | ||
public boolean perform(DynamicBuild dynamicBuild, Launcher launcher, BuildListener listener) { | ||
CoberturaPublisher publisher = new CoberturaPublisher(pluginInputFiles, false, false, false, false, false, false, false, null, 0); | ||
|
||
try { | ||
return publisher.perform(((AbstractBuild) dynamicBuild), launcher, listener); | ||
} catch (Exception e) { | ||
e.printStackTrace(listener.getLogger()); | ||
return false; | ||
} | ||
} | ||
|
||
} | ||
``` | ||
###LICENSE | ||
|
||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014, Groupon, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
**Installation Steps** | ||
1. [Install Plugin](#install-plugin) | ||
2. [Mongodb setup](#mongodb-setup) | ||
3. [Github oauth plugin configuration](#github-oauth-plugin-setup) | ||
4. [DotCi plugin configuration](#dotci-plugin-configuration) | ||
5. [Configure package management](#configure-package-management) | ||
|
||
## Install Plugin | ||
- Install DotCi plugin from the update center. This should also install [github-oauth-plugin](https://wiki.jenkins-ci.org/display/JENKINS/Github+OAuth+Plugin) | ||
|
||
## Mongodb setup | ||
Install [mongodb](https://www.mongodb.org/) accessible to your jenkins instance. | ||
|
||
## Github oauth plugin configuration | ||
* Register an OAuth [application](https://github.com/settings/applications/new) with github to obtain Client-ID/Secret. | ||
|
||
* Go to 'Manage Jenkins' > 'Configure Global Security' | ||
Under 'Security Realm' select 'Github Authentication Plugin' and fill out required oauth credentials. | ||
|
||
|
||
## DotCi plugin configuration | ||
Got to 'Manage Jenkins'> 'Configure System' and fill out required information under DotCi Configuration | ||
|
||
![dotci setup](/screenshots/dotci-plugin-configuration.png) | ||
|
||
## Configure package management | ||
|
||
There are two options for installing packages that the build needs, | ||
|
||
- **Docker** - Install docker on jenkins slaves where builds would run. | ||
- **Non-Docker** - DotCi calls a shell function 'install_packages' with requested packages and languages specified in the enviroment | ||
section of .ci.yml. It is upto you to provide implementation of this shell function available to jenkins slave running dotci build. | ||
|
||
|
||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
**Table of Contents** | ||
- [Setup a new DotCi Job] (#setup-a-new-dotci-job) | ||
- [.ci.yml reference] (#ciyml-reference) | ||
- [Environment Section](#environment-section) | ||
- [Build Section](#build-section) | ||
- [Notifications Section](#notifications-section) | ||
- [Plugins Section](#plugins-section) | ||
- [Templating .ci.yml] (#templating-ciyml) | ||
- [Environment Variables](#environment-variables) | ||
- [Groovy templating](#groovy-templating ) | ||
- [Build url shortcuts](#build-url-shortcuts) | ||
|
||
|
||
## Setup a new DotCi Job | ||
- Click new DotCi job on side-panel | ||
|
||
![New Job](screenshots/new-job-link.png) | ||
- Select Github Org and click new job | ||
|
||
![org](screenshots/create-job.png) | ||
|
||
## .ci.yml reference | ||
Build automatically inherits .ci.yml based on language that is autodetected. | ||
|
||
Check in a .ci.yml with **overrides** for overriding the [defaults](../src/main/resources/com/groupon/jenkins/buildconfiguration/base_yml) | ||
|
||
.ci.yml file is divided into four major sections | ||
|
||
#### Environment Section | ||
|
||
- Non-docker builds | ||
```yaml | ||
environment: | ||
vars: #These vars are exported in shell before build starts | ||
BUNDLE_WITHOUT: production:development | ||
|
||
language: ruby # always single value | ||
|
||
language_versions: # single value or list of values (extra row in build matrix) | ||
- ree-1.8.7 | ||
- mri-1.8.7 | ||
|
||
packages: #extra arguments that passed into install_packages call | ||
- memcached-1.4.5 | ||
``` | ||
|
||
- Docker builds | ||
```yaml | ||
environment: | ||
vars: #These vars are exported as docker env variables | ||
BUNDLE_WITHOUT: production:development | ||
language: ruby # always single value | ||
image:< docker/image-name> # Optional if repo has Dockerfile which would be used to build an image | ||
services: #list or single value | ||
- acme/mongo:1.4 | ||
- acme/redis:2.4 | ||
``` | ||
Images specified under `services` section would be [linked](http://docs.docker.io/use/working_with_links_names/) to | ||
the container specified with `image` ( or `Dockerfile`) | ||
|
||
#### Build Section | ||
|
||
```yaml | ||
build: | ||
skip: true #skips build | ||
before: # single command or list of commands (run serially on each matrix job) | ||
- gem install -y rubygems-update | ||
- update_rubygems | ||
|
||
info: #print machine/environment diagnostics | ||
- bundle --version | ||
|
||
# single command or list of commands (run serially on each matrix job) | ||
#run: rake test | ||
# or as a hash map (each entry run in parallel in build matrix) | ||
run: | ||
unit: bundle exec rake spec:units | ||
integration: bundle exec rake spec:integration | ||
acceptance: # Each parallelized step can also have multiple serial commands | ||
- bundle exec rake cucumber | ||
- bundle exec rake cucumber:javascript | ||
|
||
#starts a new build - initializes environment and runs this script | ||
after: cap deploy staging | ||
``` | ||
#### Notifications Section | ||
```yaml | ||
notifications: #list of notifications, notified ONLY on build fail and branch recovery. | ||
- email: #as always it can be single value or a list | ||
- kittah@gmail.com | ||
- kitty@gmail.com | ||
- hipchat: room-name # single or list of roomids | ||
- campfire: Devops | ||
``` | ||
|
||
#### Plugins Section | ||
```yaml | ||
plugins: | ||
- test_output: | ||
format: tap |junit | ||
- artifacts: blah.txt # this needs to be ant file specifier format ( see http://ant.apache.org/manual/Types/fileset.html) | ||
# configure your project's Build Environment: "Delete workspace before build starts" to avoid accumulative artifacts | ||
- checkstyle #expects file to be target/checkstyle-result.xml | ||
- cobertura #expects target/site/cobertura/coverage.xml | ||
- findbugs #expects target/findbugsXml.xml | ||
``` | ||
|
||
## Templating .ci.yml | ||
|
||
#### Environment Variables | ||
In addition to [Jenkins build variables](https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-JenkinsSetEnvironmentVariables), DotCi provides the following global variables | ||
- ```DOTCI_BRANCH``` current branch | ||
- ```DOTCI``` always true | ||
- ```CI``` always true | ||
- ```DOTCI_SHA``` current sha being built | ||
- ```GIT_URL``` git url | ||
- ```DOTCI_PUSHER``` github username whose git push triggred this build | ||
- ```DOTCI_PULL_REQUEST``` pull request number being built | ||
|
||
#### Groovy templating | ||
|
||
`.ci.yml` is a [groovy template](http://groovy.codehaus.org/Groovy+Templates) which is run through a groovy preprocessor before build starts. | ||
|
||
For example, an if statement can be used to choose a ruby version based on a branch. | ||
|
||
``` yaml | ||
environment: | ||
language: ruby | ||
language_versions: | ||
<% if( DOTCI_BRANCH != 'migration') { %> | ||
- '1.9.2_p290' | ||
<% } %> | ||
- '1.9.3_p290' | ||
``` | ||
|
||
or send extra notification to yourself when a build fails | ||
|
||
```yaml | ||
notifications: | ||
<% if( DOTCI_PUSHER == 'joe') { %> | ||
- sms: 1234344453 | ||
<% } %> | ||
|
||
``` | ||
|
||
## Build Url shortcuts | ||
* Fetch builds by git sha ( `job/meow/23/sha?value=<sha>`) | ||
* Or branch specific permalinks (`lastSuccessfulMaster`) . | ||
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.