PowerShell calls the Jira Rest API to implement statistics on the number of individual bugs submitted

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.