Discover how a bimodal integration strategy can address the major data management challenges facing your organization today.
Get the Report →Automate Jira Integration Tasks from PowerShell
Are you in search of a quick and easy way to access Jira data from PowerShell? This article demonstrates how to utilize the Jira Cmdlets for tasks like connecting to Jira data, automating operations, downloading data, and more.
The CData Cmdlets for Jira are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Jira.
PowerShell Cmdlets or ADO.NET Provider?
The Cmdlets are not only a PowerShell interface to Jira, but also an SQL interface; this tutorial shows how to use both to retrieve Jira data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Jira. To access Jira data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Jira.
Once you have acquired the necessary connection properties, accessing Jira data in PowerShell can be enabled in three steps.
To connect to JIRA, provide the User and Password. Additionally, provide the Url; for example, https://yoursitename.atlassian.net.
PowerShell
-
Install the module:
Install-Module JIRACmdlets
-
Connect:
$jira = Connect-JIRA -User "$User" -Password "$Password" -Url "$Url"
-
Search for and retrieve data:
$reporterdisplayname = "Bob" $issues = Select-JIRA -Connection $jira -Table "Issues" -Where "ReporterDisplayName = `'$ReporterDisplayName`'" $issues
You can also use the Invoke-JIRA cmdlet to execute SQL commands:
$issues = Invoke-JIRA -Connection $jira -Query 'SELECT * FROM Issues WHERE ReporterDisplayName = @ReporterDisplayName' -Params @{'@ReporterDisplayName'='Bob'}
ADO.NET
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Jira\lib\System.Data.CData.JIRA.dll")
-
Connect to Jira:
$conn= New-Object System.Data.CData.JIRA.JIRAConnection("User=admin;Password=123abc;Url=https://yoursitename.atlassian.net;") $conn.Open()
-
Instantiate the JIRADataAdapter, execute an SQL query, and output the results:
$sql="SELECT Summary, TimeSpent from Issues" $da= New-Object System.Data.CData.JIRA.JIRADataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.summary $_.timespent }