jira_attachment_importer-csv.rb
#Utilizes the above methods to attach the specified file to the specified issue within the specified project.
Utilizes the above methods to attach the specified file to the specified issue within the specified project.
Utilizes the above methods to attach the specified file to the specified issue within the specified project .
def attach(project_name, issue_name, attachment_path)
	project_id = getProjectId(project_name)
	attachment_arr = "#{attachment_path}".split("\\")
	attachment_name = "#{attachment_arr[attachment_arr.length() - 1]}"
	if "#{project_id}" != ""
		issue_id = getIssueId(project_id, issue_name)
		if "#{issue_id}" != ""
			issueObj = findIssue(issue_id)
			attachment = JIRA::Resource::Attachment.new $client, issue: issueObj
			saved = attachment.save! 'file' => attachment_path
			if "#{saved}" == "true"
				puts "File attachment[SUCCESSFUL] -- #{attachment_name} was uploaded to the #{issue_name} story."
				write_to_file("File attachment[SUCCESSFUL] -- #{attachment_name} was uploaded to the #{issue_name} story.", "info")
			else
				puts "File attachment[FAILED] -- Could not upload #{attachment_name} to the #{issue_name} story." 
				$upload_failed_count += 1
				write_to_file("File attachment[FAILED] -- Could not upload #{attachment_name} to the #{issue_name} story.", "error")
			end
		else
			puts "Issue #{issue_name} was not found in the #{project_name} project scope -- Could not upload the #{attachment_name} to it."
			$upload_failed_count += 1
			write_to_file("Issue #{issue_name} was not found in the #{project_name} project scope -- Could not upload the #{attachment_name} to it.", "error")
		end
	else 
		puts "Project #{project_name} was not found -- Could not upload the #{attachment_name} File to the #{issue_name} story."
		$upload_failed_count += 1
		write_to_file("Project #{project_name} was not found -- Could not upload the #{attachment_name} File to the #{issue_name} story.", "error")
	end
end
def attach ( project_name , issue_name , attachment_path ) project_id = getProjectId ( project_name ) attachment_arr = "#{attachment_path}" . split ( "\\" ) attachment_name = "#{attachment_arr[attachment_arr.length() - 1]}" if "#{project_id}" != "" issue_id = getIssueId ( project_id , issue_name ) if "#{issue_id}" != "" issueObj = findIssue ( issue_id ) attachment = JIRA :: Resource :: Attachment . new $client , issue : issueObj saved = attachment . save! 'file' => attachment_path if "#{saved}" == "true" puts "File attachment[SUCCESSFUL] -- #{attachment_name} was uploaded to the #{issue_name} story." write_to_file ( "File attachment[SUCCESSFUL] -- #{attachment_name} was uploaded to the #{issue_name} story." , "info" ) else puts "File attachment[FAILED] -- Could not upload #{attachment_name} to the #{issue_name} story." $upload_failed_count += 1 write_to_file ( "File attachment[FAILED] -- Could not upload #{attachment_name} to the #{issue_name} story." , "error" ) end else puts "Issue #{issue_name} was not found in the #{project_name} project scope -- Could not upload the #{attachment_name} to it." $upload_failed_count += 1 write_to_file ( "Issue #{issue_name} was not found in the #{project_name} project scope -- Could not upload the #{attachment_name} to it." , "error" ) end else puts "Project #{project_name} was not found -- Could not upload the #{attachment_name} File to the #{issue_name} story." $upload_failed_count += 1 write_to_file ( "Project #{project_name} was not found -- Could not upload the #{attachment_name} File to the #{issue_name} story." , "error" ) end end
Utilizes the above methods to attach the specified file to the specified issue within the specified project.
Utilizes the above methods to attach the specified file to the specified issue within the specified project .
#write which file was not uploaded successfully to error log in main dir #Write Error to log #increment error count #Write Error to log #increment error count
project_name
issue_name
attachment_path