The Invoke-webrequest and net.client of PowerShell combine to achieve the statistics of the number of Jira submissions for individual projects, the code is as follows:
$content= @{username= ' user name ';p assword=' Password '}$JSON=$content|convertto-json-Compress$jiraUri="http://jira.ms.netease.com"$apiUri=$jiraUri+"/rest/auth/1/session"$res= Invoke-webrequest-uri$apiUri-method Post-body$JSON-contenttype application/JSON$webClient= new-Object Net.webclient#Set encoding style here.$webClient. Encoding = [System.text.encoding]::getencoding ("Utf-8")$webClient. Headers.add ("Cookies",$res. headers["Set-cookie"])$keyWord= Read-host"Please enter the search keywords (more than one keyword separated by a space)"$JQL="Reporter in (user name) and text ~ '"+$keyWord+"'"$JSON= @"{ "Jql": "$JQL", "StartAt": 0,"MaxResults": +,"Fields": [ "Summary", "Status", "Assignee" ]}"@$apiUri="/rest/api/2/search"$uri=$jiraUri+$apiUri#Post JSON must added header.$webClient. Headers.add ("Content-type","Application/json");$searchResult=$webClient. Uploadstring ($uri,$JSON)#Get issues.$issues= ($searchResult| convertfrom-Json). Issuesforeach($issue inch $issues){ $issue. Fields.summary} Write-host"Jira related to key words are common"$issues. Count"a"-Foregroundcolor Greenread-host
Save the script to the desktop right-click PowerShell to run, or directly in the ISE press F5 to run repeatedly, the effect is as follows:
Principle: According to JQL to achieve through the title keyword to find Jira, also used the Jira rest API.
PowerShell calls the Jira Rest API to implement statistics on the number of individual bugs submitted