jenkins_tracker 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.2"
4
+ - "1.9.3"
data/README.md CHANGED
@@ -1,17 +1,21 @@
1
1
  # JenkinsTracker
2
2
 
3
+ [![Build Status](https://travis-ci.org/prashantrajan/jenkins_tracker.png?branch=master)](https://travis-ci.org/prashantrajan/jenkins_tracker)
4
+ [![Gem Version](https://badge.fury.io/rb/jenkins_tracker.png)](http://badge.fury.io/rb/jenkins_tracker)
5
+
3
6
  `jenkins_tracker` is a command line utility packaged as a [RubyGem](https://rubygems.org) that integrates [Jenkins](http://jenkins-ci.org/) build information with
4
7
  the relevant [Pivotal Tracker](https://www.pivotaltracker.com) stories within a project.
5
8
 
6
- It's ideally run as a Post Build Action in Jenkins.
7
-
8
9
  This utility makes some very specific assumptions about your Jenkins environment:-
9
10
 
10
11
  * Git as your SCM via the [Jenkins Git Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin).
11
12
 
12
13
  * The Jenkins build changelog file is available at `$JENKINS_HOME/jobs/$JOB_NAME/builds/$BUILD_NUMBER/changelog.xml`.
14
+ The changelog contents look like this [example](https://github.com/prashantrajan/jenkins_tracker/blob/master/spec/fixtures/git_changelog.txt).
13
15
 
14
- * Ability to execute Ruby scripts.
16
+ * Ability to execute Ruby 1.9.x scripts.
17
+
18
+ * Environment variables exists for `$JENKINS_HOME`, `$JOB_NAME`, `$BUILD_NUMBER` & `$BUILD_URL`.
15
19
 
16
20
 
17
21
  The following are required for your Pivotal Tracker project:-
@@ -36,7 +40,17 @@ Or install it yourself as:
36
40
 
37
41
  ## Usage
38
42
 
39
- TODO: Write usage instructions here
43
+ # Assuming environment variables for $JENKINS_HOME, $JOB_NAME, $BUILD_NUMBER & $BUILD_URL exists
44
+ $ bundle exec jenkins_tracker integrate --tracker-token ABC123456 --tracker-project-id 123456
45
+ # => Successfully integrated Jenkins Job ($JOB_NAME) with Pivotal Tracker Project (123456)
46
+
47
+ It's best to run this utility as a Post Build Action in Jenkins:
48
+
49
+ ![Jenkins Post Build Action Screenshot](https://raw.github.com/prashantrajan/static_assets/master/jenkins_tracker/images/jenkins_post_build_action.jpg)
50
+
51
+ The integration will result in comments being added to the relevant Pivotal Tracker stories:
52
+
53
+ ![Jenkins Post Build Action Screenshot](https://raw.github.com/prashantrajan/static_assets/master/jenkins_tracker/images/tracker_comment.jpg)
40
54
 
41
55
 
42
56
  ## Contributing
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -4,6 +4,7 @@ require 'ostruct'
4
4
  require 'rest-client'
5
5
 
6
6
  require 'jenkins_tracker/version'
7
+ require 'jenkins_tracker/exceptions'
7
8
  require 'jenkins_tracker/util'
8
9
  require 'jenkins_tracker/tracker_client'
9
10
  require 'jenkins_tracker/base'
@@ -5,6 +5,8 @@ module JenkinsTracker
5
5
  attr_reader :changelog, :tracker_client, :job_name, :build_url
6
6
 
7
7
  def initialize(options = {})
8
+ raise FileNotFoundError, "Changelog file not found at: #{options[:changelog_file]}" unless File.file?(options[:changelog_file])
9
+
8
10
  @changelog = File.read(options[:changelog_file])
9
11
  @tracker_client = TrackerClient.new(:token => options[:tracker_token])
10
12
  @job_name = options[:job_name]
@@ -22,8 +22,8 @@ module JenkinsTracker
22
22
  ).integrate_job_with_tracker(tracker_project_id)
23
23
 
24
24
  say "Successfully integrated Jenkins Job (#{job_name}) with Pivotal Tracker Project (#{tracker_project_id})", :green
25
- rescue
26
- # do nothing
25
+ rescue FileNotFoundError => e
26
+ say e.message, :red
27
27
  end
28
28
  end
29
29
 
@@ -0,0 +1,10 @@
1
+ module JenkinsTracker
2
+
3
+ # our base error class
4
+ class Error < StandardError
5
+ end
6
+
7
+ class FileNotFoundError < Error
8
+ end
9
+
10
+ end
@@ -1,3 +1,3 @@
1
1
  module JenkinsTracker
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -15,6 +15,21 @@ describe JenkinsTracker::Base do
15
15
  expect(obj.job_name).to eq('foo_job')
16
16
  expect(obj.build_url).to eq('http://jenkins.bitium/com/foo_job/3')
17
17
  end
18
+
19
+ context 'when changelog file does not exist' do
20
+ it 'raises a FileNotFoundError' do
21
+ changelog_file = '/a/non-existent/file/path'
22
+
23
+ expect {
24
+ described_class.new(
25
+ :changelog_file => changelog_file,
26
+ :tracker_token => 'xxx',
27
+ :job_name => 'foo_job',
28
+ :build_url => 'http://jenkins.bitium/com/foo_job/3'
29
+ )
30
+ }.to raise_error(JenkinsTracker::FileNotFoundError, "Changelog file not found at: #{changelog_file}")
31
+ end
32
+ end
18
33
  end
19
34
 
20
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jenkins_tracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -85,6 +85,7 @@ extra_rdoc_files: []
85
85
  files:
86
86
  - .gitignore
87
87
  - .rspec
88
+ - .travis.yml
88
89
  - Gemfile
89
90
  - MIT-LICENSE
90
91
  - README.md
@@ -94,6 +95,7 @@ files:
94
95
  - lib/jenkins_tracker.rb
95
96
  - lib/jenkins_tracker/base.rb
96
97
  - lib/jenkins_tracker/cli.rb
98
+ - lib/jenkins_tracker/exceptions.rb
97
99
  - lib/jenkins_tracker/tracker_client.rb
98
100
  - lib/jenkins_tracker/util.rb
99
101
  - lib/jenkins_tracker/version.rb
@@ -118,7 +120,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
120
  version: '0'
119
121
  segments:
120
122
  - 0
121
- hash: 1872917664060546366
123
+ hash: 4101774404869784256
122
124
  required_rubygems_version: !ruby/object:Gem::Requirement
123
125
  none: false
124
126
  requirements:
@@ -127,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
129
  version: '0'
128
130
  segments:
129
131
  - 0
130
- hash: 1872917664060546366
132
+ hash: 4101774404869784256
131
133
  requirements: []
132
134
  rubyforge_project:
133
135
  rubygems_version: 1.8.24