Skip to content

Commit

Permalink
Add Jira server integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Glib Briia committed May 8, 2020
1 parent 7da5198 commit 1c30db4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ assertthat-bdd-features -h
Usage: assertthat-bdd-features [options]
-a, --accessKey ACCESS_KEY Access key same as env variable ASSERTTHAT_ACCESS_KEY
-s, --secretKey SECRET_KEY Secret key same as env variable ASSERTTHAT_SECRET_KEY
-u, --jiraServerUrl SERVER_URL Jira Server URL (Only for jira server integration) e.g. https://mycompanyjira.com
-p, --projectId PROJECT_ID Jira project id
-o, --outputFolder OUTPUT_FOLDER Featured output folder - default ./features
-m, --mode MODE Mode one of automated,manual,both - deafult automated
Expand All @@ -51,6 +52,7 @@ assertthat-bdd-report -h
Usage: assertthat-bdd-report [options]
-a, --accessKey ACCESS_KEY Access key same as env variable ASSERTTHAT_ACCESS_KEY
-s, --secretKey SECRET_KEY Secret key same as env variable ASSERTTHAT_SECRET_KEY
-u, --jiraServerUrl SERVER_URL Jira Server URL (Only for jira server integration) e.g. https://mycompanyjira.com
-p, --projectId PROJECT_ID Jira project id
-n, --runName RUN_NAME The name of the run - default 'Test run dd MMM yyyy HH:mm:ss'
-f JSON_FOLDER_PATH, Json report folder - default ./reports
Expand Down
4 changes: 2 additions & 2 deletions assertthat-bdd.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = %q{assertthat-bdd}
s.version = "1.1.0"
s.date = %q{2018-12-09}
s.version = "1.2.0"
s.date = %q{2020-05-08}
s.summary = %q{AssertThat bdd integration for Ruby}
s.authors = ["Glib Briia"]
s.email = '[email protected]'
Expand Down
3 changes: 2 additions & 1 deletion bin/assertthat-bdd-features
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
require 'assertthat-bdd'
require 'optparse'

VERSION = '1.0.2'
VERSION = '1.2.0'

options = {}
OptionParser.new do |opt|
opt.on('-a','--accessKey ACCESS_KEY', 'Access key same as env variable ASSERTTHAT_ACCESS_KEY') { |o| options[:accessKey] = o }
opt.on('-s','--secretKey SECRET_KEY', 'Secret key same as env variable ASSERTTHAT_SECRET_KEY') { |o| options[:secretKey] = o }
opt.on('-u','--jiraServerUrl SERVER_URL', 'Jira server URL') { |o| options[:jiraServerUrl] = o }
opt.on('-p','--projectId PROJECT_ID', 'Jira project id') { |o| options[:projectId] = o }
opt.on('-o','--outputFolder OUTPUT_FOLDER', 'Featured output folder - default ./features') { |o| options[:outputFolder] = o }
opt.on('-m','--mode MODE', 'Mode one of automated,manual,both - deafult automated') { |o| options[:mode] = o }
Expand Down
3 changes: 2 additions & 1 deletion bin/assertthat-bdd-report
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
require 'assertthat-bdd'
require 'optparse'

VERSION = '1.0.2'
VERSION = '1.2.0'

options = {}
OptionParser.new do |opt|
opt.on('-a','--accessKey ACCESS_KEY', 'Access key same as env variable ASSERTTHAT_ACCESS_KEY') { |o| options[:accessKey] = o }
opt.on('-s','--secretKey SECRET_KEY', 'Secret key same as env variable ASSERTTHAT_SECRET_KEY') { |o| options[:secretKey] = o }
opt.on('-u','--jiraServerUrl SERVER_URL', 'Jira server URL') { |o| options[:jiraServerUrl] = o }
opt.on('-p', '--projectId PROJECT_ID', 'Jira project id') { |o| options[:projectId] = o }
opt.on('-n','--runName RUN_NAME', 'The name of the run - default \'Test run dd MMM yyyy HH:mm:ss\'') { |o| options[:runName] = o }
opt.on('-f','--jsonReportFolder JSON_FOLDER_PATH', 'Json report folder - default ./reports') { |o| options[:mode] = o }
Expand Down
6 changes: 4 additions & 2 deletions lib/assertthat-bdd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

module AssertThatBDD
class Features
def self.download(accessKey: ENV['ASSERTTHAT_ACCESS_KEY'], secretKey: ENV['ASSERTTHAT_ACCESS_KEY'], projectId: nil, outputFolder: './features/', proxy: nil, mode: 'automated', jql: '')
def self.download(accessKey: ENV['ASSERTTHAT_ACCESS_KEY'], secretKey: ENV['ASSERTTHAT_ACCESS_KEY'], projectId: nil, outputFolder: './features/', proxy: nil, mode: 'automated', jql: '', jiraServerUrl: nil)
RestClient.proxy = proxy unless proxy.nil?
url = 'https://bdd.assertthat.app/rest/api/1/project/'+ projectId +'/features'
url = jiraServerUrl+"/rest/assertthat/latest/project/"+projectId+"/client/features" unless jiraServerUrl.nil?
resource = RestClient::Resource.new(url, :user => accessKey, :password => secretKey, :content_type => 'application/zip')
begin
contents = resource.get(:accept => 'application/zip', params: {mode: mode, jql: jql})
Expand Down Expand Up @@ -46,7 +47,8 @@ def self.download(accessKey: ENV['ASSERTTHAT_ACCESS_KEY'], secretKey: ENV['ASSER

class Report
def self.upload(accessKey: ENV['ASSERTTHAT_ACCESS_KEY'], secretKey: ENV['ASSERTTHAT_ACCESS_KEY'], projectId: nil, runName: 'Test run '+Time.now.strftime("%d %b %Y %H:%M:%S"), jsonReportFolder: './reports', jsonReportIncludePattern: '.*.json' )
url = "https://bdd.assertthat.app/rest/api/1/project/" + projectId + "/report"
url = "https://bdd.assertthat.app/rest/api/1/project/" + projectId + "/report"
url = jiraServerUrl+"/rest/assertthat/latest/project/"+projectId+"/client/report" unless jiraServerUrl.nil?
files = Find.find(jsonReportFolder).grep(/#{jsonReportIncludePattern}/)
puts "*** INFO: #{files.count} files found matching parretn #{jsonReportIncludePattern}:"
puts "*** INFO: #{files}"
Expand Down

0 comments on commit 1c30db4

Please sign in to comment.