gocd_pre_push 1.2 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rspec +2 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +45 -11
- data/README.md +1 -0
- data/bin/gocd_pre_push +7 -11
- data/gocd_pre_push.gemspec +3 -3
- data/lib/gocd_pre_push/build_informer.rb +1 -1
- data/lib/gocd_pre_push/build_officer.rb +12 -10
- data/lib/gocd_pre_push/linker.rb +25 -0
- data/lib/gocd_pre_push/version.rb +1 -1
- data/lib/rubygems_plugin.rb +7 -0
- data/spec/gocd_pre_push/build_informer_spec.rb +52 -0
- data/spec/gocd_pre_push/build_officer_spec.rb +25 -0
- data/spec/gocd_pre_push/gocd_server_spec.rb +17 -0
- data/spec/gocd_pre_push/pipelines.yml +8 -0
- data/spec/spec_helper.rb +103 -0
- data/templates/pre_push.rb +4 -8
- metadata +35 -9
- data/scripts/symlink_git_hooks.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d5925d7af5d26d9d32842815ad7f7cb6e848b85b144f1fe9b6cd9def71f07efd
|
4
|
+
data.tar.gz: c72e21c59f3fc372d00b36472fc928c7431cf6cf160fc1c8a5cced00a3818026
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49e9556295eef2793d8021096b9bf97d3a808d14a9dc8b588d6c22e97c6864b451608e6173cac8234050b791928cd43c02ea6b7ea68844328c3fff6e79a2bc78
|
7
|
+
data.tar.gz: afdc3fcc9e12d99396bac5667d96a8739cab810d603450be8b739ff71fe08784bd36f8fa7cecd028b91a4395b1b373f2b24b3ca07dcf98f37b463e716ab8ab1e
|
data/.rspec
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,27 +1,61 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (5.
|
4
|
+
activesupport (5.2.1)
|
5
5
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
|
-
i18n (
|
6
|
+
i18n (>= 0.7, < 2)
|
7
7
|
minitest (~> 5.1)
|
8
8
|
tzinfo (~> 1.1)
|
9
|
-
|
10
|
-
|
9
|
+
cobravsmongoose (0.0.2)
|
10
|
+
concurrent-ruby (1.0.5)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
domain_name (0.5.20180417)
|
13
|
+
unf (>= 0.0.5, < 1.0.0)
|
14
|
+
gocd (1.3)
|
11
15
|
activesupport
|
16
|
+
cobravsmongoose (~> 0.0.2)
|
12
17
|
json
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
+
rest-client
|
19
|
+
http-cookie (1.0.3)
|
20
|
+
domain_name (~> 0.5)
|
21
|
+
i18n (1.1.1)
|
22
|
+
concurrent-ruby (~> 1.0)
|
23
|
+
json (2.1.0)
|
24
|
+
mime-types (3.2.2)
|
25
|
+
mime-types-data (~> 3.2015)
|
26
|
+
mime-types-data (3.2018.0812)
|
27
|
+
minitest (5.11.3)
|
28
|
+
netrc (0.11.0)
|
29
|
+
rest-client (2.0.2)
|
30
|
+
http-cookie (>= 1.0.2, < 2.0)
|
31
|
+
mime-types (>= 1.16, < 4.0)
|
32
|
+
netrc (~> 0.8)
|
33
|
+
rspec (3.8.0)
|
34
|
+
rspec-core (~> 3.8.0)
|
35
|
+
rspec-expectations (~> 3.8.0)
|
36
|
+
rspec-mocks (~> 3.8.0)
|
37
|
+
rspec-core (3.8.0)
|
38
|
+
rspec-support (~> 3.8.0)
|
39
|
+
rspec-expectations (3.8.2)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.8.0)
|
42
|
+
rspec-mocks (3.8.0)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.8.0)
|
45
|
+
rspec-support (3.8.0)
|
46
|
+
thread_safe (0.3.6)
|
47
|
+
tzinfo (1.2.5)
|
18
48
|
thread_safe (~> 0.1)
|
49
|
+
unf (0.1.4)
|
50
|
+
unf_ext
|
51
|
+
unf_ext (0.0.7.5)
|
19
52
|
|
20
53
|
PLATFORMS
|
21
54
|
ruby
|
22
55
|
|
23
56
|
DEPENDENCIES
|
24
|
-
gocd (~>
|
57
|
+
gocd (~> 1.3)
|
58
|
+
rspec
|
25
59
|
|
26
60
|
BUNDLED WITH
|
27
|
-
1.
|
61
|
+
1.16.1
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
Check GOCD pipelines status before pushing your code
|
3
3
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/gocd_pre_push.svg)](https://badge.fury.io/rb/gocd_pre_push)
|
5
|
+
[![Twitter Follow](https://img.shields.io/twitter/follow/Ajit5ingh.svg?style=social)](https://twitter.com/Ajit5ingh)
|
5
6
|
|
6
7
|
## Why gocd_pre_push?
|
7
8
|
When an agile team grows and becomes distributed, there comes a problem of keeping the pipelines green. To have less pipeline failures agile team follows one of the best practices, which is to not to push the code on a red pipeline. But how often we make an effort to open the GOCD dashboard and check the status of the pipelines. And the problem becomes worse when developer is not sure about what pipelines will be effected by their code.
|
data/bin/gocd_pre_push
CHANGED
@@ -2,32 +2,28 @@
|
|
2
2
|
|
3
3
|
require_relative '../templates/pre_push.rb'
|
4
4
|
require_relative '../templates/pipelines.rb'
|
5
|
-
require_relative '../
|
5
|
+
require_relative '../lib/gocd_pre_push/linker.rb'
|
6
6
|
require_relative '../lib/gocd_pre_push/pretty_printer.rb'
|
7
7
|
|
8
8
|
include GOCD_PRE_PUSH::PrettyPrinter
|
9
9
|
|
10
|
-
def create_symlink
|
11
|
-
print_info "Creating symlink ./.git/hooks => hooks"
|
12
|
-
print_info "Your old hooks will be saved inside ./.git/hooks.old\n"
|
13
|
-
symlink_git_hooks
|
14
|
-
end
|
15
|
-
|
16
10
|
def execute
|
11
|
+
linker = GOCD_PRE_PUSH::Linker.new
|
12
|
+
|
17
13
|
if ARGV[0] == 'create'
|
18
14
|
print_info "Creating pre-push hook.."
|
19
15
|
`mkdir hooks`
|
20
16
|
File.write('hooks/pre-push', pre_push_hook)
|
21
17
|
print_info "Done!\n"
|
22
18
|
print_info "Adding executable permission to pre-push hook.."
|
23
|
-
`
|
19
|
+
`chmod 777 hooks/pre-push`
|
24
20
|
print_success "Please update the pre-push hook with your gocd server url, username and password\n"
|
25
|
-
|
21
|
+
linker.symlink_git_hooks
|
26
22
|
|
27
23
|
print_success "Adding pipelines.yml, change the pipelines as per your requirement!\n"
|
28
|
-
File.write('
|
24
|
+
File.write('gocd_pre_push.yml', pipelines)
|
29
25
|
elsif ARGV[0] == 'use_hooks'
|
30
|
-
|
26
|
+
linker.symlink_git_hooks
|
31
27
|
else
|
32
28
|
print_info "Right usage is:"
|
33
29
|
print_info "gocd_pre_push create => For first time setup"
|
data/gocd_pre_push.gemspec
CHANGED
@@ -6,8 +6,7 @@ require_relative './lib/gocd_pre_push/version.rb'
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = 'gocd_pre_push'
|
8
8
|
s.version = GOCD_PRE_PUSH::VERSION
|
9
|
-
s.
|
10
|
-
s.summary = 'Check GOCD pipeline status before pushing your changes to central repo'
|
9
|
+
s.summary = 'Check GoCD pipeline status before pushing your changes to central repo'
|
11
10
|
s.description = s.summary
|
12
11
|
s.authors = ['Ajit Singh']
|
13
12
|
s.email = 'jeetsingh.ajit@gamil.com'
|
@@ -19,5 +18,6 @@ Gem::Specification.new do |s|
|
|
19
18
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
20
19
|
s.require_paths = ["lib"]
|
21
20
|
|
22
|
-
s.add_dependency 'gocd', '~>
|
21
|
+
s.add_dependency 'gocd', '~> 1.3'
|
22
|
+
s.add_development_dependency "rspec"
|
23
23
|
end
|
@@ -11,7 +11,7 @@ module GOCD_PRE_PUSH
|
|
11
11
|
|
12
12
|
pipelines = YAML::load_file pipelines
|
13
13
|
pipelines.map! { |pipeline| pipeline_stage_name pipeline }.flatten!
|
14
|
-
@pipelines = GOCD::PipelineGroup.new
|
14
|
+
@pipelines = GOCD::PipelineGroup.new(pipelines, cache: true)
|
15
15
|
end
|
16
16
|
|
17
17
|
def information_available?
|
@@ -1,31 +1,33 @@
|
|
1
1
|
require_relative 'build_informer'
|
2
|
+
require_relative 'pretty_printer'
|
2
3
|
|
3
4
|
module GOCD_PRE_PUSH
|
4
5
|
class BuildOfficer
|
6
|
+
include GOCD_PRE_PUSH::PrettyPrinter
|
7
|
+
|
5
8
|
def initialize(concerned_pipelines, server_details)
|
6
9
|
@build_informer = BuildInformer.new concerned_pipelines, server_details
|
7
10
|
end
|
8
11
|
|
9
12
|
def investigate
|
10
|
-
|
13
|
+
print_info "Build cop is on duty.."
|
14
|
+
red_pipelines = @build_informer.red_pipelines
|
11
15
|
|
12
|
-
if
|
13
|
-
red_pipelines
|
14
|
-
report_red_builds red_pipelines
|
15
|
-
suspects_found = red_pipelines.any?
|
16
|
+
if red_pipelines.any?
|
17
|
+
report_red_builds(red_pipelines)
|
16
18
|
else
|
17
|
-
|
18
|
-
suspects_found = true
|
19
|
+
print_success 'All clear!'
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
+
red_pipelines.any?
|
22
23
|
end
|
23
24
|
|
24
25
|
private
|
25
26
|
def report_red_builds(pipelines)
|
26
|
-
|
27
|
+
print_info "The cop found below crimes, all will be judged..\n"
|
28
|
+
pipelines.each_with_index do |pipeline, index|
|
27
29
|
pipeline, stage = pipeline.name.gsub(' ', '').split('::')
|
28
|
-
|
30
|
+
print_error " #{index+1}. #{pipeline}'s #{stage} stage is failing.\n"
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative 'pretty_printer'
|
2
|
+
|
3
|
+
module GOCD_PRE_PUSH
|
4
|
+
class Linker
|
5
|
+
include GOCD_PRE_PUSH::PrettyPrinter
|
6
|
+
|
7
|
+
def symlink_git_hooks
|
8
|
+
return unless File.exists?('./hooks')
|
9
|
+
|
10
|
+
print_info "Creating symlink ./.git/hooks => hooks"
|
11
|
+
print_info "Your old hooks will be saved inside ./.git/hooks.old\n"
|
12
|
+
|
13
|
+
`if [[ ! -L "./.git/hooks" && -d "./.git/hooks" ]]
|
14
|
+
then
|
15
|
+
echo -e "\nHooks folder exists moving content into ./.git/hooks.old"
|
16
|
+
mv "./.git/hooks" "./.git/hooks.old"
|
17
|
+
fi`
|
18
|
+
`if [[ ! -L "./.git/hooks" && -d "./hooks" ]]
|
19
|
+
then
|
20
|
+
echo -e "\nCreating symlink ./.git/hooks => hooks"
|
21
|
+
ln -s "../hooks/" ".git/hooks"
|
22
|
+
fi`
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require './lib/gocd_pre_push/gocd_server'
|
2
|
+
require './lib/gocd_pre_push/build_informer'
|
3
|
+
|
4
|
+
describe 'BuildInformer' do
|
5
|
+
gocd_server = GOCD_PRE_PUSH::GocdServer.with do |server|
|
6
|
+
server.url = 'http://yourgocdserverurl.com'
|
7
|
+
server.username = 'your_gocd_username'
|
8
|
+
server.password = 'your_gocd_password'
|
9
|
+
end
|
10
|
+
|
11
|
+
context '#pipelines' do
|
12
|
+
it 'should create a group of pipelines from given yml file' do
|
13
|
+
pipelines = ['MyAwesomeProject :: spec', 'MyAwesomeProject :: integration', 'MyAwesomeProject :: generate_artifacts', 'MyAwesomeProject_Smoke :: smoke']
|
14
|
+
expect(GOCD::PipelineGroup).to receive(:new).with(pipelines, {cache: true})
|
15
|
+
|
16
|
+
GOCD_PRE_PUSH::BuildInformer.new './spec/gocd_pre_push/pipelines.yml', gocd_server
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should return the pipelines group' do
|
20
|
+
build_informer = GOCD_PRE_PUSH::BuildInformer.new './spec/gocd_pre_push/pipelines.yml', gocd_server
|
21
|
+
|
22
|
+
expect(build_informer.pipelines.is_a?(GOCD::PipelineGroup)).to be_truthy
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should tell if information is available' do
|
27
|
+
pipelines_group = instance_double('PipelineGroup', information_available?: 'true')
|
28
|
+
|
29
|
+
expect(GOCD::PipelineGroup).to receive(:new).and_return(pipelines_group)
|
30
|
+
build_informer = GOCD_PRE_PUSH::BuildInformer.new './spec/gocd_pre_push/pipelines.yml', gocd_server
|
31
|
+
|
32
|
+
expect(build_informer.information_available?).to be_truthy
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should return the red pipelines' do
|
36
|
+
pipelines_group = instance_double('PipelineGroup', red_pipelines: 'red_pipelines')
|
37
|
+
|
38
|
+
expect(GOCD::PipelineGroup).to receive(:new).and_return(pipelines_group)
|
39
|
+
build_informer = GOCD_PRE_PUSH::BuildInformer.new './spec/gocd_pre_push/pipelines.yml', gocd_server
|
40
|
+
|
41
|
+
expect(build_informer.red_pipelines).to eq('red_pipelines')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should return when any of the pipelines is red' do
|
45
|
+
pipelines_group = instance_double('PipelineGroup', any_red?: true)
|
46
|
+
|
47
|
+
expect(GOCD::PipelineGroup).to receive(:new).and_return(pipelines_group)
|
48
|
+
build_informer = GOCD_PRE_PUSH::BuildInformer.new './spec/gocd_pre_push/pipelines.yml', gocd_server
|
49
|
+
|
50
|
+
expect(build_informer.any_red?).to be_truthy
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require './lib/gocd_pre_push/build_informer'
|
2
|
+
require './lib/gocd_pre_push/build_officer'
|
3
|
+
|
4
|
+
describe 'BuildOffice' do
|
5
|
+
context 'investigate' do
|
6
|
+
it 'should return true when any of the pipelines is red' do
|
7
|
+
pipelines = instance_double('pipeline', name: 'MyPipeline :: my_stage')
|
8
|
+
build_informer = instance_double('build_informer', information_available?: true, red_pipelines: [pipelines])
|
9
|
+
|
10
|
+
expect(GOCD_PRE_PUSH::BuildInformer).to receive(:new).and_return(build_informer)
|
11
|
+
officer = GOCD_PRE_PUSH::BuildOfficer.new 'concerned_pipelines', 'server_details'
|
12
|
+
|
13
|
+
expect(officer.investigate).to be_truthy
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should return false when all pipelines are green' do
|
17
|
+
build_informer = instance_double('build_informer', information_available?: true, red_pipelines: [])
|
18
|
+
|
19
|
+
expect(GOCD_PRE_PUSH::BuildInformer).to receive(:new).and_return(build_informer)
|
20
|
+
officer = GOCD_PRE_PUSH::BuildOfficer.new 'concerned_pipelines', 'server_details'
|
21
|
+
|
22
|
+
expect(officer.investigate).to be_falsey
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require './lib/gocd_pre_push/gocd_server'
|
2
|
+
|
3
|
+
describe 'GocdServer' do
|
4
|
+
context 'initialize' do
|
5
|
+
it 'should initialize the gocd server with url, username and password' do
|
6
|
+
gocd_server = GOCD_PRE_PUSH::GocdServer.with do |server|
|
7
|
+
server.url = 'http://serverurl.com'
|
8
|
+
server.username = 'myusername'
|
9
|
+
server.password = 'pass'
|
10
|
+
end
|
11
|
+
|
12
|
+
expect(gocd_server.url).to eq('http://serverurl.com')
|
13
|
+
expect(gocd_server.username).to eq('myusername')
|
14
|
+
expect(gocd_server.password).to eq('pass')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
+
# users commonly want.
|
17
|
+
#
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
RSpec.configure do |config|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
+
# assertions if you prefer.
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
26
|
+
# defined using `chain`, e.g.:
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
29
|
+
# ...rather than:
|
30
|
+
# # => "be bigger than 2"
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
+
config.mock_with :rspec do |mocks|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
+
# a real object. This is generally recommended, and will default to
|
39
|
+
# `true` in RSpec 4.
|
40
|
+
mocks.verify_partial_doubles = true
|
41
|
+
end
|
42
|
+
|
43
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
44
|
+
# have no way to turn it off -- the option exists only for backwards
|
45
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
46
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
47
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
48
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
49
|
+
|
50
|
+
# The settings below are suggested to provide a good initial experience
|
51
|
+
# with RSpec, but feel free to customize to your heart's content.
|
52
|
+
=begin
|
53
|
+
# This allows you to limit a spec run to individual examples or groups
|
54
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
55
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
56
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
57
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
58
|
+
config.filter_run_when_matching :focus
|
59
|
+
|
60
|
+
# Allows RSpec to persist some state between runs in order to support
|
61
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
62
|
+
# you configure your source control system to ignore this file.
|
63
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
64
|
+
|
65
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
66
|
+
# recommended. For more details, see:
|
67
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
68
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
69
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
70
|
+
config.disable_monkey_patching!
|
71
|
+
|
72
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
73
|
+
# be too noisy due to issues in dependencies.
|
74
|
+
config.warnings = true
|
75
|
+
|
76
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
77
|
+
# file, and it's useful to allow more verbose output when running an
|
78
|
+
# individual spec file.
|
79
|
+
if config.files_to_run.one?
|
80
|
+
# Use the documentation formatter for detailed output,
|
81
|
+
# unless a formatter has already been configured
|
82
|
+
# (e.g. via a command-line flag).
|
83
|
+
config.default_formatter = 'doc'
|
84
|
+
end
|
85
|
+
|
86
|
+
# Print the 10 slowest examples and example groups at the
|
87
|
+
# end of the spec run, to help surface which specs are running
|
88
|
+
# particularly slow.
|
89
|
+
config.profile_examples = 10
|
90
|
+
|
91
|
+
# Run specs in random order to surface order dependencies. If you find an
|
92
|
+
# order dependency and want to debug it, you can fix the order by providing
|
93
|
+
# the seed, which is printed after each run.
|
94
|
+
# --seed 1234
|
95
|
+
config.order = :random
|
96
|
+
|
97
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
98
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
99
|
+
# test failures related to randomization by passing the same `--seed` value
|
100
|
+
# as the one that triggered the failure.
|
101
|
+
Kernel.srand config.seed
|
102
|
+
=end
|
103
|
+
end
|
data/templates/pre_push.rb
CHANGED
@@ -5,21 +5,17 @@ def pre_push_hook
|
|
5
5
|
require 'gocd_pre_push'
|
6
6
|
|
7
7
|
include GOCD_PRE_PUSH
|
8
|
+
include GOCD_PRE_PUSH::PrettyPrinter
|
8
9
|
|
9
|
-
#Add your gocd server details here
|
10
10
|
gocd_server = GocdServer.with do |server|
|
11
11
|
server.url = 'http://yourgocdserverurl.com'
|
12
12
|
server.username = 'your_gocd_username'
|
13
13
|
server.password = 'your_gocd_password'
|
14
14
|
end
|
15
15
|
|
16
|
-
#Don't change the pipelines path unless
|
17
|
-
|
16
|
+
#Don't change the pipelines path unless gocd_pre_push.yml is not present in the repo's root folder
|
17
|
+
crime_found = BuildOfficer.new('gocd_pre_push.yml', gocd_server).investigate
|
18
18
|
|
19
|
-
if
|
20
|
-
abort 'Can not push!'
|
21
|
-
else
|
22
|
-
print 'All dependent pipelines are green! You can push your changes :)'
|
23
|
-
end
|
19
|
+
abort if crime_found
|
24
20
|
HOOK
|
25
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gocd_pre_push
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '2.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ajit Singh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gocd
|
@@ -16,15 +16,29 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Check GoCD pipeline status before pushing your changes to central repo
|
28
42
|
email: jeetsingh.ajit@gamil.com
|
29
43
|
executables:
|
30
44
|
- gocd_pre_push
|
@@ -32,6 +46,7 @@ extensions: []
|
|
32
46
|
extra_rdoc_files: []
|
33
47
|
files:
|
34
48
|
- ".gitignore"
|
49
|
+
- ".rspec"
|
35
50
|
- Gemfile
|
36
51
|
- Gemfile.lock
|
37
52
|
- LICENCE.txt
|
@@ -42,9 +57,15 @@ files:
|
|
42
57
|
- lib/gocd_pre_push/build_informer.rb
|
43
58
|
- lib/gocd_pre_push/build_officer.rb
|
44
59
|
- lib/gocd_pre_push/gocd_server.rb
|
60
|
+
- lib/gocd_pre_push/linker.rb
|
45
61
|
- lib/gocd_pre_push/pretty_printer.rb
|
46
62
|
- lib/gocd_pre_push/version.rb
|
47
|
-
-
|
63
|
+
- lib/rubygems_plugin.rb
|
64
|
+
- spec/gocd_pre_push/build_informer_spec.rb
|
65
|
+
- spec/gocd_pre_push/build_officer_spec.rb
|
66
|
+
- spec/gocd_pre_push/gocd_server_spec.rb
|
67
|
+
- spec/gocd_pre_push/pipelines.yml
|
68
|
+
- spec/spec_helper.rb
|
48
69
|
- templates/pipelines.rb
|
49
70
|
- templates/pre_push.rb
|
50
71
|
homepage: https://github.com/ajitsing/gocd_pre_push.git
|
@@ -67,8 +88,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
88
|
version: '0'
|
68
89
|
requirements: []
|
69
90
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
91
|
+
rubygems_version: 2.7.6
|
71
92
|
signing_key:
|
72
93
|
specification_version: 4
|
73
|
-
summary: Check
|
74
|
-
test_files:
|
94
|
+
summary: Check GoCD pipeline status before pushing your changes to central repo
|
95
|
+
test_files:
|
96
|
+
- spec/gocd_pre_push/build_informer_spec.rb
|
97
|
+
- spec/gocd_pre_push/build_officer_spec.rb
|
98
|
+
- spec/gocd_pre_push/gocd_server_spec.rb
|
99
|
+
- spec/gocd_pre_push/pipelines.yml
|
100
|
+
- spec/spec_helper.rb
|
@@ -1,12 +0,0 @@
|
|
1
|
-
def symlink_git_hooks
|
2
|
-
`if [[ ! -L "./.git/hooks" && -d "./.git/hooks" ]]
|
3
|
-
then
|
4
|
-
echo -e "\nHooks folder exists moving content into ./.git/hooks.old"
|
5
|
-
mv "./.git/hooks" "./.git/hooks.old"
|
6
|
-
fi`
|
7
|
-
`if [[ ! -L "./.git/hooks" && -d "./hooks" ]]
|
8
|
-
then
|
9
|
-
echo -e "\nCreating symlink ./.git/hooks => hooks"
|
10
|
-
ln -s "../hooks/" ".git/hooks"
|
11
|
-
fi`
|
12
|
-
end
|