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
0 parents
commit a1df485
Showing
22 changed files
with
812 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 @@ | ||
*.js |
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,2 @@ | ||
src | ||
spec |
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,20 @@ | ||
Copyright (c) 2011 Corey Donohoe | ||
|
||
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,25 @@ | ||
deps: | ||
@test `which coffee` || echo "You need to have CoffeeScript in your PATH.\nPlease install it using `brew install coffee-script` or `npm install coffee-script`." | ||
|
||
build: deps | ||
@coffee -o lib src/ | ||
@coffee -o spec spec/ | ||
|
||
install: deps | ||
@coffee -o lib src/ | ||
@npm install | ||
|
||
publish: deps | ||
@coffee -o lib src/ | ||
@npm publish | ||
|
||
test: build | ||
@vows spec/*_spec.js --spec | ||
|
||
http: build | ||
@node lib/app.js | ||
|
||
dev: deps | ||
@coffee -wc --bare -o lib src/ | ||
|
||
.PHONY: all |
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,51 @@ | ||
[![Velma Dinkley said "Jinkies"][1]][2] | ||
|
||
> Her catchphrases are: "**Jinkies!**", "My glasses! I can't see without my glasses!", and "You wouldn't hit someone wearing glasses, would you?". | ||
-------------------------------------------------------------------------- | ||
|
||
Jinkies is a [coffee-script](http://jashkenas.github.com/coffee-script/) interface to the [Jenkins](http://jenkins-ci.org) ([Continuous Integration](http://martinfowler.com/articles/continuousIntegration.html)) server's JSON API. | ||
|
||
I'd written half of this before I realized I was cloning a lot of [hudson.rb](https://github.com/cowboyd/hudson.rb). | ||
|
||
-------------------------------------------------------------------------- | ||
|
||
You need a current [node.js](http://nodejs.org) development environment. | ||
|
||
[Setting up your environment](https://github.com/atmos/jinkies/wiki/Development) | ||
--------------------------------------------------------------------------------------------------- | ||
|
||
Jinkies is [available](https://github.com/atmos/jinkies) under an [MIT license](https://github.com/atmos/jinkies/blob/master/LICENSE). | ||
|
||
[If you care about testing your hacks](https://github.com/atmos/jinkies/wiki/Testing) | ||
------------------------------------------------------------------------------------- | ||
|
||
Jinkies has tests that you can run too. | ||
|
||
[If you're interested with GitHub integration](https://github.com/atmos/jinkies/wiki/The-Web-API) | ||
------------------------------------------------------------------------------------- | ||
|
||
Jinkies works as a post-receive endpoint for GitHub webhooks. | ||
|
||
[If you're interested in the command line](https://github.com/atmos/jinkies/wiki/Command-Line) | ||
----------------------------------------------------------------------------------------------- | ||
|
||
Jinkies gives you a simple executable that uses the library. | ||
|
||
$ bin/jinkies -h | ||
Usage jinkies [options] | ||
|
||
Available options: | ||
-h, --help Display the help information | ||
-j, --job JOB Specify the jenkins job | ||
-t, --trigger-build Trigger a build for the jenkins jobs | ||
-b, --branch BRANCH Specify the jenkins build should locate | ||
-s, --sha1 SHA1 Specify the SHA1 the jenkins build should locate | ||
-p, --express-port PORT Specify the express port, defaults to 45678 | ||
-e, --express-app Start the express webhook endpoint | ||
-r, --robot Start the robot!!!!1 | ||
-d, --server SERVER Specify jinkies server to use | ||
-a, --all List all the jobs on the jenkins server | ||
|
||
[1]: http://f.cl.ly/items/370L3N2X363C2S38110W/img-rn_jinkies.jpeg | ||
[2]: http://en.wikipedia.org/wiki/Velma_Dinkley |
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,123 @@ | ||
#!/usr/bin/env coffee | ||
require.paths.unshift(__dirname + "/../src") | ||
|
||
Color = require "ansi-color" | ||
Jinkies = require "jinkies" | ||
OptParse = require "optparse" | ||
|
||
Switches = [ | ||
[ "-h", "--help", "Display the help information"], | ||
[ "-j", "--job JOB", "Specify the jenkins job"], | ||
[ "-t", "--trigger-build", "Trigger a build for the jenkins jobs"], | ||
[ "-b", "--branch BRANCH", "Specify the jenkins build should locate"], | ||
[ "-s", "--sha1 SHA1", "Specify the SHA1 the jenkins build should locate"], | ||
[ "-p", "--express-port PORT", "Specify the express port, defaults to 45678"], | ||
[ "-e", "--express-app", "Start the express webhook endpoint"], | ||
[ "-r", "--robot", "Start a shell robot"], | ||
[ "-c", "--campfire", "Start a campfire notifier"], | ||
[ "-d", "--server SERVER", "Specify jinkies server to use"], | ||
[ "-a", "--all", "List all the jobs on the jenkins server"] | ||
] | ||
|
||
Options = | ||
mode: "all" | ||
sha1: "" | ||
port: 45678 | ||
job: process.env.JENKINS_JOB || "default" | ||
server: process.env.JENKINS_SERVER || "http://localhost:8080" | ||
branch: process.env.JENKINS_BRANCH || "master" | ||
|
||
Parser = new OptParse.OptionParser(Switches) | ||
Parser.banner = "Usage jinkies [options]" | ||
|
||
Parser.on "server", (opt, value) -> | ||
Options.server = value | ||
|
||
Parser.on "all", -> | ||
Options.mode = "all" | ||
|
||
Parser.on "branch", (opt, value) -> | ||
Options.branch = value | ||
Options.mode = "job" | ||
|
||
Parser.on "sha1", (opt, value) -> | ||
Options.sha1 = value | ||
Options.mode = "job" | ||
|
||
Parser.on "job", (opt, value) -> | ||
Options.job = value | ||
Options.mode = "job" | ||
|
||
Parser.on "robot", (opt, value) -> | ||
Options.mode = "robot" | ||
|
||
Parser.on "campfire", (opt, value) -> | ||
Options.mode = "campfire" | ||
|
||
Parser.on "trigger-build", (opt, value) -> | ||
Options.mode = "build" | ||
|
||
Parser.on "express-app", (opt, value) -> | ||
Options.mode = "express" | ||
|
||
Parser.on "express-port", (opt, value) -> | ||
Options.port = value | ||
|
||
Parser.on "help", (opt, value) -> | ||
console.log Parser.toString() | ||
process.exit 0 | ||
|
||
Parser.parse process.ARGV | ||
|
||
server = new Jinkies.Server(Options.server) | ||
|
||
switch Options.mode | ||
when "all" | ||
server.jobs (err, jobs) -> | ||
for job in jobs | ||
do (job) -> | ||
job.color = "green" if job.color == "blue" | ||
console.log("#{Color.set(job.name, job.color)} - #{job.url}") | ||
when "job" | ||
job = server.job_for Options.job | ||
job.info (err, info) -> | ||
info.color = "green" if info.color == "blue" | ||
console.log("#{Color.set(info.name, info.color)} - #{info.url}") | ||
job.build_for info.lastSuccessfulBuild.number, (err, build) -> | ||
console.log(" Last Successful Build - ##{build.number} - #{build.branch} - #{build.sha1}") | ||
if info.lastFailedBuild | ||
job.build_for info.lastFailedBuild.number, (err, build) -> | ||
console.log(" Last Failed Build - ##{build.number} - #{build.branch} - #{build.sha1}") | ||
else | ||
console.log(" Last Failed Build - never") | ||
when "build" | ||
job = server.job_for Options.job | ||
job.triggerBuild Options.branch, "{}", (err, data) -> | ||
status = Color.set("failed", "red") | ||
status = Color.set("succeeded", "green") if data.status == true | ||
console.log "Build request for #{job.name}: #{status}" | ||
|
||
when "express" | ||
app = Jinkies.ExpressApp | ||
app.jinkies = new Jinkies.Server(Options.server) | ||
app.listen(Options.port) | ||
process.on 'uncaughtException', (err) -> | ||
console.log('Caught exception: ' + err) | ||
|
||
when "robot" | ||
robot = new Jinkies.Robot(Options.server) | ||
robot.on "build", (err, build, notification) -> | ||
console.log(notification) | ||
robot.run() | ||
when "campfire" | ||
campfireOptions = | ||
room: process.env.JENKINS_CAMPFIRE_ROOM | ||
token: process.env.JENKINS_CAMPFIRE_TOKEN | ||
account: process.env.JENKINS_CAMPFIRE_ACCOUNT | ||
|
||
robot = new Jinkies.CampfireRobot(Options.server, campfireOptions) | ||
robot.run() | ||
|
||
#console.log(Options) | ||
|
||
# vim:ft=coffee |
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,34 @@ | ||
{ | ||
"name": "jinkies", | ||
"description": "Translate GitHub post commits to Jenkins CI builds and back", | ||
"keywords": "github post-receive hudson jenkins", | ||
"author": "Corey Donohoe", | ||
"version": "0.1.2", | ||
"licenses": [{ | ||
"type": "MIT", | ||
"url": "http://github.com/atmos/jinkies/raw/master/LICENSE" | ||
}], | ||
|
||
"repository" : { | ||
"type" : "git", | ||
"url" : "http://github.com/atmos/jinkies.git" | ||
}, | ||
|
||
"dependencies" : { | ||
"coffee-script" : ">= 1.0.1", | ||
"express" : ">= 1.0.7", | ||
"optparse" : ">= 1.0.1", | ||
"ansi-color" : ">= 0.2.1" | ||
}, | ||
|
||
"engines": { | ||
"node": ">=0.2.5" | ||
}, | ||
"directories": { | ||
"lib": "./lib" | ||
}, | ||
"main": "./lib/jinkies", | ||
"bin": { | ||
"jinkies": "./bin/jinkies" | ||
} | ||
} |
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,15 @@ | ||
Helper = require "./helper" | ||
Vows = Helper.Vows | ||
assert = Helper.Assert | ||
Options = Helper.default_options | ||
|
||
Vows | ||
.describe("Jenkins Base64 Library") | ||
.addBatch | ||
"Jenkins Base64 can": | ||
topic: -> | ||
new Buffer "Jinkies Paradise" | ||
"encode strings": (buffer) -> | ||
assert.equal buffer.toString("base64"), "Smlua2llcyBQYXJhZGlzZQ==" | ||
|
||
.export(module) |
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 @@ | ||
Helper = require "./helper" | ||
Vows = Helper.Vows | ||
assert = Helper.Assert | ||
Options = Helper.default_options | ||
|
||
Campfire = require("jenkins/utils/campfire").Campfire | ||
|
||
Vows | ||
.describe("Jenkins Campfire Library") | ||
.addBatch | ||
"Jenkins Campfire can": | ||
topic: -> | ||
new Campfire({"token": Options.campfire.token, "account": Options.campfire.account}) | ||
"retrieve its token": (campfire) -> | ||
assert.equal campfire.token, Options.campfire.token | ||
"retrieve its account name": (campfire) -> | ||
assert.equal campfire.account, Options.campfire.account | ||
#"Jenkins Campfire Users can": | ||
#topic: -> | ||
#cf = new Campfire({"token": Options.campfire.token, "account": Options.campfire.account}) | ||
#cf.User Options.campfire.user, @callback | ||
#"retrieves a user's information": (user) -> | ||
#console.log user | ||
"Jenkins Campfire Rooms can": | ||
topic: -> | ||
cf = new Campfire({"token": Options.campfire.token, "account": Options.campfire.account}) | ||
cf.Rooms @callback | ||
"retrieves a list of rooms": (rooms) -> | ||
console.log rooms | ||
"Jenkins Campfire Rooms can": | ||
topic: -> | ||
cf = new Campfire({"token": Options.campfire.token, "account": Options.campfire.account}) | ||
room = cf.Room(Options.campfire.room) | ||
room.speak "Vows Test Post", @callback | ||
"retrieve its token": (err, data) -> | ||
assert.equal "Vows Test Post", data.message.body | ||
|
||
.export(module) |
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,16 @@ | ||
require.paths.unshift(__dirname + "/../lib") | ||
|
||
Vows = require "vows" | ||
exports.Vows = Vows | ||
|
||
Assert = require "assert" | ||
exports.Assert = Assert | ||
|
||
exports.default_options = | ||
job: process.env.JENKINS_JOB || "default" | ||
server: process.env.JENKINS_SERVER || "http://localhost:8080" | ||
campfire: | ||
user: process.env.JENKINS_CAMPFIRE_USER || 42 | ||
room: process.env.JENKINS_CAMPFIRE_ROOM || 42 | ||
token: process.env.JENKINS_CAMPFIRE_TOKEN || "xxxxxxxxxxxxxxxxxxxxxxxx" | ||
account: process.env.JENKINS_CAMPFIRE_ACCOUNT || "unknown" |
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,41 @@ | ||
Helper = require "./helper" | ||
Vows = Helper.Vows | ||
assert = Helper.Assert | ||
Options = Helper.default_options | ||
|
||
Job = require("jinkies").Job | ||
|
||
Vows | ||
.describe("Jenkins Job API") | ||
.addBatch | ||
"Jenkins Jobs can": | ||
topic: -> | ||
new Job Options.server, Options.job | ||
"get the hostname": (job) -> | ||
assert.equal job.host, Options.server | ||
"get the job name": (job) -> | ||
assert.equal job.name, Options.job | ||
"Jenkins Jobs#builds can": | ||
topic: -> | ||
j = new Job Options.server, Options.job | ||
j.builds @callback | ||
"get a list of builds": (err, info) -> | ||
latest = info[0]["number"] | ||
assert.ok latest.toString().match(/\d+/) | ||
"Jenkins Jobs#status can": | ||
topic: -> | ||
j = new Job Options.server, Options.job | ||
j.status @callback | ||
"get the status of a job": (err, status) -> | ||
assert.ok status | ||
"Jenkins Jobs#build_for can": | ||
topic: -> | ||
j = new Job Options.server, Options.job | ||
j.build_for 10, @callback | ||
"get info about a build number": (err, build) -> | ||
assert.ok build.status | ||
assert.equal build.sha1 , "3ba21ee37953c344f698171cb2ab725ef7f9b776" | ||
assert.equal build.branch, "origin/master" | ||
assert.equal build.output, "#{Options.server}/job/#{Options.job}/10/consoleText" | ||
|
||
.export(module) |
Oops, something went wrong.