brpm_module_servicenow 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +37 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -0
- data/Rakefile +23 -0
- data/automations/transition_change_request.meta +11 -0
- data/automations/transition_change_request.rb +2 -0
- data/config.yml +8 -0
- data/lib/snow_rest_client.rb +31 -0
- data/module.gemspec +38 -0
- data/tests/spec_helper.rb +33 -0
- data/tests/transition_change_request_spec.rb +29 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MmZjYTI1ZGY4M2QzOTVjZDc3ZjU4MDdhZWUzNGFjNmI4MjcxZjFhOQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NDI2MTU4ZDQzNjQ4YzUzNDI0ZTFmMDFlMDI0ZGNiOGRlY2E3MGU3Mw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MTljMDAxMDYwZmYwMDU1MDdkMzQwOGQzZjIwZjdjNmEzY2ZkNDRjZTlhMjM5
|
10
|
+
ZjUwYTYwZDIzNDFhNjUyMmFkY2Y3ZWIxYTE1OWIxMGYxMWVmZDVmMzE0ODkx
|
11
|
+
YTEyYWJkYmE4MWVmNzg3YTI3YmViOTMyZDZjN2UxMGFjYmZhN2Y=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
M2VhODUyZjZhMWZkNTUzY2FiNDliOTk0ZDZjOWNlZDhmOTEwNjNhMTljYzMz
|
14
|
+
NzE3NWJlNWRmNjcwODc4MjMzZDYyMWRjZGVhZDRiZjE2MDJhNTUxMWY5ZmQx
|
15
|
+
Yjc0NjBkNjNkMTA2M2JkOGY1NmJjNjdhMDk0YzFlYzVhOGNmMWI=
|
data/.gitignore
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
Gemfile.lock
|
30
|
+
.ruby-gemset
|
31
|
+
|
32
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
33
|
+
.rvmrc
|
34
|
+
|
35
|
+
.DS_Store
|
36
|
+
|
37
|
+
.idea
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3-p392
|
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
# Immediately sync all stdout so that tools like buildbot can
|
6
|
+
# immediately load in the output.
|
7
|
+
$stdout.sync = true
|
8
|
+
$stderr.sync = true
|
9
|
+
|
10
|
+
# Change to the directory of this file.
|
11
|
+
Dir.chdir(File.expand_path("../", __FILE__))
|
12
|
+
|
13
|
+
# This installs the tasks that help with gem creation and
|
14
|
+
# publishing.
|
15
|
+
Bundler::GemHelper.install_tasks
|
16
|
+
|
17
|
+
# Install the `spec` task so that we can run tests.
|
18
|
+
RSpec::Core::RakeTask.new do |task|
|
19
|
+
task.pattern = "tests/**/*_spec.rb"
|
20
|
+
end
|
21
|
+
|
22
|
+
# Default task is to run the unit tests
|
23
|
+
task :default => "spec"
|
@@ -0,0 +1,11 @@
|
|
1
|
+
params:
|
2
|
+
change_request_id:
|
3
|
+
name: Change request id
|
4
|
+
target_change_request_status:
|
5
|
+
name: Change request status
|
6
|
+
type: in-list-single
|
7
|
+
list_pairs: 1,Pending|2,Open|3,Work in Progress|4,Closed Complete|5,Closed Incomplete|6,Closed Skipped
|
8
|
+
|
9
|
+
|
10
|
+
integration_server_type: ServiceNow
|
11
|
+
|
data/config.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
version: 0.0.1
|
2
|
+
|
3
|
+
author: Niek Bartholomeus
|
4
|
+
email: niek.bartholomeus@gmail.com
|
5
|
+
homepage: https://github.com/BMC-RLM/brpm_module_servicenow
|
6
|
+
license: MIT
|
7
|
+
summary: ServiceNow automation scripts and libraries to run on top of the BRPM Content framework
|
8
|
+
description: ServiceNow automation scripts and libraries to run on top of the BRPM Content framework. See https://github.com/BMC-RLM/brpm_content_framework for more information about the BRPM Content framework
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
class SnowRestClient
|
5
|
+
def initialize(integration_settings = BrpmAuto.integration_settings)
|
6
|
+
@url = integration_settings.dns
|
7
|
+
@username = integration_settings.username
|
8
|
+
@password = integration_settings.password
|
9
|
+
|
10
|
+
@api_url = "#{@url}/api/now/table"
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_state_id_from_state_label(label)
|
14
|
+
case label
|
15
|
+
when "Pending"; -5
|
16
|
+
when "Open"; 1
|
17
|
+
when "Work in Progress"; 2
|
18
|
+
when "Closed Complete"; 3
|
19
|
+
when "Closed Incomplete"; 4
|
20
|
+
when "Closed Skipped"; 7
|
21
|
+
else
|
22
|
+
raise "Unsupported state label: #{label}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def update_record(table, id, fields)
|
27
|
+
url = "#{@api_url}/#{table}/#{id}"
|
28
|
+
|
29
|
+
Rest.put(url, fields, { :username => @username, :password => @password })["response"]
|
30
|
+
end
|
31
|
+
end
|
data/module.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
config = YAML.load_file(File.join(File.dirname(__FILE__), "config.yml"))
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = File.basename(File.expand_path(File.dirname(__FILE__))).sub("-#{config["version"]}", "")
|
7
|
+
spec.version = config["version"]
|
8
|
+
spec.platform = Gem::Platform::RUBY
|
9
|
+
spec.license = config["license"]
|
10
|
+
spec.authors = [config["author"]]
|
11
|
+
spec.email = config["email"]
|
12
|
+
spec.homepage = config["homepage"]
|
13
|
+
spec.summary = config["summary"]
|
14
|
+
spec.description = config["description"]
|
15
|
+
|
16
|
+
spec.add_runtime_dependency "brpm_content_framework", ">=0.2.11"
|
17
|
+
|
18
|
+
if config["dependencies"]
|
19
|
+
config["dependencies"].each do |dependency|
|
20
|
+
if dependency.is_a?(Hash)
|
21
|
+
modul = dependency.keys[0]
|
22
|
+
options = dependency.values[0]
|
23
|
+
else
|
24
|
+
modul = dependency
|
25
|
+
options = {}
|
26
|
+
end
|
27
|
+
spec.add_runtime_dependency modul, options["version"]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
unless ENV["BRPM_CONTENT_FRAMEWORK_DEPLOYMENT"]
|
32
|
+
spec.add_development_dependency "rake"
|
33
|
+
spec.add_development_dependency "rspec"
|
34
|
+
end
|
35
|
+
|
36
|
+
spec.files = `git ls-files`.split("\n")
|
37
|
+
spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
38
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require "brpm_script_executor"
|
3
|
+
|
4
|
+
def setup_brpm_auto
|
5
|
+
FileUtils.mkdir_p "/tmp/brpm_content"
|
6
|
+
|
7
|
+
BrpmAuto.setup( get_default_params.merge!(get_integration_params_for_servicenow) )
|
8
|
+
|
9
|
+
BrpmAuto.require_module "brpm_module_servicenow"
|
10
|
+
|
11
|
+
@snow_rest_client = SnowRestClient.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_default_params
|
15
|
+
params = {}
|
16
|
+
params['also_log_to_console'] = 'true'
|
17
|
+
|
18
|
+
params['brpm_url'] = 'http://brpm-content.pulsar-it.be:8088/brpm'
|
19
|
+
params['brpm_api_token'] = ENV["BRPM_API_TOKEN"]
|
20
|
+
|
21
|
+
params['output_dir'] = "/tmp/brpm_content"
|
22
|
+
|
23
|
+
params
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_integration_params_for_servicenow
|
27
|
+
params = {}
|
28
|
+
params["SS_integration_dns"] = 'https://dev14275.service-now.com'
|
29
|
+
params["SS_integration_username"] = 'admin'
|
30
|
+
params["SS_integration_password"] = ENV["SERVICENOW_PASSWORD"]
|
31
|
+
|
32
|
+
params
|
33
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe 'transition issue' do
|
4
|
+
before(:all) do
|
5
|
+
setup_brpm_auto
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '' do
|
9
|
+
it 'transition a change request in ServiceNow' do
|
10
|
+
params = get_default_params
|
11
|
+
params = params.merge(get_integration_params_for_servicenow)
|
12
|
+
|
13
|
+
params["change_request_id"] = "2f31ef3b0fbb42000d3f758ce1050edd"
|
14
|
+
|
15
|
+
params["target_change_request_status"] = "Pending"
|
16
|
+
BrpmScriptExecutor.execute_automation_script("brpm_module_servicenow", "transition_change_request", params)
|
17
|
+
|
18
|
+
params["target_change_request_status"] = "Open"
|
19
|
+
BrpmScriptExecutor.execute_automation_script("brpm_module_servicenow", "transition_change_request", params)
|
20
|
+
|
21
|
+
params["target_change_request_status"] = "Work in Progress"
|
22
|
+
BrpmScriptExecutor.execute_automation_script("brpm_module_servicenow", "transition_change_request", params)
|
23
|
+
|
24
|
+
params["target_change_request_status"] = "Closed Complete"
|
25
|
+
BrpmScriptExecutor.execute_automation_script("brpm_module_servicenow", "transition_change_request", params)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: brpm_module_servicenow
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Niek Bartholomeus
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: brpm_content_framework
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.11
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.11
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: ServiceNow automation scripts and libraries to run on top of the BRPM
|
56
|
+
Content framework. See https://github.com/BMC-RLM/brpm_content_framework for more
|
57
|
+
information about the BRPM Content framework
|
58
|
+
email: niek.bartholomeus@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- .ruby-version
|
65
|
+
- Gemfile
|
66
|
+
- Rakefile
|
67
|
+
- automations/transition_change_request.meta
|
68
|
+
- automations/transition_change_request.rb
|
69
|
+
- config.yml
|
70
|
+
- lib/snow_rest_client.rb
|
71
|
+
- module.gemspec
|
72
|
+
- tests/spec_helper.rb
|
73
|
+
- tests/transition_change_request_spec.rb
|
74
|
+
homepage: https://github.com/BMC-RLM/brpm_module_servicenow
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.1.9
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: ServiceNow automation scripts and libraries to run on top of the BRPM Content
|
98
|
+
framework
|
99
|
+
test_files: []
|