Module: JiraFixVersionRelease

Defined in:
lib/jira_fix_version_release.rb,
lib/jira_fix_version_release/version.rb,
lib/jira_fix_version_release/jira_options.rb

Defined Under Namespace

Classes: JIRAOptions

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.execute_options(options) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/jira_fix_version_release.rb', line 87

def self.execute_options(options)
	fix_version = options[:fix_version]
	
	jira = JIRAOptions.new(options[:username], options[:password], options[:jira_domain])

	puts "Running script please wait...", ""
	issues = jira.getUnreleasedJiraTickets(options[:project_key], options)

	puts "Discovered ready to release tickets!"

	release = jira.createFixVersion(fix_version)
	puts "Fix version: #{fix_version} created in JIRA"

	issues.each do |issue|
		#puts issue['key']
		jira.updateFixVersion(issue['key'], fix_version)
	end
	puts "Successfully updated Fix Versions!"

	issues.each do |issue|
		if options[:commits] != nil
			puts "Commit History"
			puts jira.getCommitMessages(issue['id'])
			STDOUT.flush
   		end
	end
	jira.releaseFixVersion(release['id'])
end

.parse(args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/jira_fix_version_release.rb', line 5

def self.parse(args)
	options = {}
	opt_parser = OptionParser.new do |opts|
		opts.banner = "Usage: jira_fix_version_release [options]"
		opts.separator " "
      	opts.separator "Specific options:"

      	opts.on("-h", "--help", "Displays help") do
       		puts opts
       		exit
     		end

      	opts.on("-u", "--username=USERNAME",
              "JIRA username is required") do |username|
	        options[:username] = username
	    end

	    opts.on("-p", "--password=PASSWORD",
              "JIRA password is required") do |password|
	        options[:password] = password
	    end

	    opts.on("-j", "--project_key=PROJECT_KEY",
              "JIRA project key is required") do |project_key|
	        options[:project_key] = project_key
	    end

	    opts.on("-v", "--fix_version=FIX_VERSION",  
     		      "JIRA fix version is required") do |v|
   			options[:fix_version] = v
 			end

	    opts.on("-f", "--jql_filter=JQL_FILTER",
              "JQL filter query is required") do |jql_filter|
	        options[:jql_filter] = jql_filter
	    end

	    opts.on("-d", "--jira_domain=JIRA_DOMAIN",  
     		      "JIRA domain is required") do |d|
   			options[:jira_domain] = d
 			end	

	    opts.on("-c", "--commits",
              "displays commit history") do |commits|
	        options[:commits] = commits
	    end	    

	end.parse!

	if options[:username] == nil
		print 'Enter JIRA username: '
   		options[:username] = gets.chomp
   	end

   	if options[:password] == nil
   		options[:password] = `read -s -p "Enter JIRA password: " password; echo $password`.chomp
   		puts ""
   	end

   	if options[:project_key] == nil
		print 'Enter JIRA project KEY: '
   		options[:project_key] = gets.chomp
   	end

   	if options[:fix_version] == nil
		print 'Enter JIRA fix version: '
   		options[:fix_version] = gets.chomp
   	end

   	if options[:jira_domain] == nil
		print 'Enter JIRA url: '
   		options[:jira_domain] = gets.chomp
   	end

   	if options[:jql_filter] == nil
		print 'Enter JQL filter: '
   		options[:jql_filter] = gets.chomp
   	end

   	return options
end