teamcity_hooks 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bin/teamcity_hooks +19 -0
- data/lib/teamcity_hooks.rb +5 -0
- data/lib/teamcity_hooks/configuration.rb +40 -0
- data/lib/teamcity_hooks/pre_commit.rb +0 -0
- data/lib/teamcity_hooks/version.rb +3 -0
- data/teamcity_hooks.gemspec +26 -0
- data/templates/pre-commit +61 -0
- metadata +129 -0
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Maher Hawash
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# TeamcityHooks
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'teamcity_hooks'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install teamcity_hooks
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/teamcity_hooks/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/teamcity_hooks
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
project_folder = FileUtils.pwd
|
6
|
+
template_folder = File.expand_path('../templates', __FILE__)
|
7
|
+
destination_folder = File.join(project_folder, 'templates')
|
8
|
+
hooks_folder = File.join(project_folder, '.git/hooks')
|
9
|
+
|
10
|
+
if File.exists?(destination_folder)
|
11
|
+
puts "Destination file already exists, are you sure you want to overwrite it (yes|no)?"
|
12
|
+
exit unless gets.chop =~ /yes/i
|
13
|
+
end
|
14
|
+
|
15
|
+
# Copy template folder to project dir
|
16
|
+
FileUtils.cp_rf(template_folder, FileUtils.cwd)
|
17
|
+
|
18
|
+
FileUtils.ln_sf(File.join(destination_folder, 'pre-commit'), File.join( hook_folder, 'pre-commit'))
|
19
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module TeamcityHooks
|
2
|
+
# @api: @configure
|
3
|
+
# TeamcityHooks.configure do |c|
|
4
|
+
# c.config_file
|
5
|
+
# c.endpoint = 'http://teamcity.renewfund.com'
|
6
|
+
# c.username = ''
|
7
|
+
# c.password = ''
|
8
|
+
# end
|
9
|
+
|
10
|
+
def configure(&block)
|
11
|
+
yield configuration
|
12
|
+
end
|
13
|
+
|
14
|
+
module_function :configure
|
15
|
+
|
16
|
+
private
|
17
|
+
def configuration
|
18
|
+
@configuration ||= Configuration.new
|
19
|
+
end
|
20
|
+
|
21
|
+
class Configuration
|
22
|
+
attr_accessor :config_file, :endpoint, :username, :password
|
23
|
+
|
24
|
+
def endpoint
|
25
|
+
@endpoint || config.endpoint
|
26
|
+
end
|
27
|
+
|
28
|
+
def username
|
29
|
+
@username || config.username
|
30
|
+
end
|
31
|
+
|
32
|
+
def password
|
33
|
+
@password || config.password
|
34
|
+
end
|
35
|
+
|
36
|
+
def config
|
37
|
+
OpenStruct.new(YALM.load_file(@config_file))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'teamcity_hooks/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "teamcity_hooks"
|
8
|
+
spec.version = TeamcityHooks::VERSION
|
9
|
+
spec.authors = ["Maher Hawash"]
|
10
|
+
spec.email = ["gmhawash@gmail.com"]
|
11
|
+
spec.summary = %q{Git hooks for teamcity}
|
12
|
+
spec.description = %q{Git hooks for teamcity}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency "teamcity-ruby-client", "~> 1.2"
|
25
|
+
spec.add_dependency "git", "~> 1.2"
|
26
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'teamcity'
|
4
|
+
require 'git'
|
5
|
+
|
6
|
+
@git = Git.open(FileUtils.pwd)
|
7
|
+
exit 0 unless branch.name == 'master'
|
8
|
+
|
9
|
+
TeamCity.configure do |c|
|
10
|
+
c.endpoint = 'http://teamcity.renewfund.com/httpAuth/app/rest'
|
11
|
+
c.http_user = 'mhawash'
|
12
|
+
c.http_password = 'seven11'
|
13
|
+
end
|
14
|
+
|
15
|
+
def green_build?
|
16
|
+
build = TeamCity.builds(buildType: 'bt281')
|
17
|
+
.reject{|x| x.status == 'UNKNOWN'}
|
18
|
+
.sort_by{|x| x.number }
|
19
|
+
.last
|
20
|
+
|
21
|
+
unless build.status == 'SUCCESS'
|
22
|
+
puts "Build is broken on Teamcity"
|
23
|
+
puts "Look here: %s" % build.webUrl
|
24
|
+
return false
|
25
|
+
end
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
29
|
+
def fixes_broken_build?
|
30
|
+
tag = Git::Lib.new.describe(last_commit, :tags => true)
|
31
|
+
tag =~ /^TC-FIX/
|
32
|
+
end
|
33
|
+
|
34
|
+
def last_commit
|
35
|
+
@last_commit ||= @git.gcommit('HEAD')
|
36
|
+
end
|
37
|
+
|
38
|
+
def branch
|
39
|
+
@branch ||= @git.object('HEAD')
|
40
|
+
end
|
41
|
+
|
42
|
+
unless green_build? || fixes_broken_build?
|
43
|
+
puts "Build is currently broken"
|
44
|
+
exit 1
|
45
|
+
end
|
46
|
+
|
47
|
+
#binding.pry
|
48
|
+
#puts TeamCity.projects
|
49
|
+
#puts TeamCity.buildtypes
|
50
|
+
#puts TeamCity.builds
|
51
|
+
|
52
|
+
# Only on master branch
|
53
|
+
# Find project builds for test (we could have more than one)
|
54
|
+
#
|
55
|
+
#List of build types
|
56
|
+
|
57
|
+
#List of changes
|
58
|
+
#http://teamcity.renewfund.com/httpAuth/app/rest/changes?buildType=id:bt281
|
59
|
+
#/httpAuth/app/rest/changes/id:40380
|
60
|
+
|
61
|
+
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: teamcity_hooks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Maher Hawash
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-05-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.6'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.6'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: teamcity-ruby-client
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.2'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.2'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: git
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.2'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.2'
|
78
|
+
description: Git hooks for teamcity
|
79
|
+
email:
|
80
|
+
- gmhawash@gmail.com
|
81
|
+
executables:
|
82
|
+
- teamcity_hooks
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files: []
|
85
|
+
files:
|
86
|
+
- .gitignore
|
87
|
+
- Gemfile
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.md
|
90
|
+
- Rakefile
|
91
|
+
- bin/teamcity_hooks
|
92
|
+
- lib/teamcity_hooks.rb
|
93
|
+
- lib/teamcity_hooks/configuration.rb
|
94
|
+
- lib/teamcity_hooks/pre_commit.rb
|
95
|
+
- lib/teamcity_hooks/version.rb
|
96
|
+
- teamcity_hooks.gemspec
|
97
|
+
- templates/pre-commit
|
98
|
+
homepage: ''
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
hash: -2314204699535350320
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
hash: -2314204699535350320
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 1.8.23
|
126
|
+
signing_key:
|
127
|
+
specification_version: 3
|
128
|
+
summary: Git hooks for teamcity
|
129
|
+
test_files: []
|