![]() |
VOOZH | about |
The CData Cmdlets for Jira Assets are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Jira Assets.
The Cmdlets are not only a PowerShell interface to Jira Assets, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Jira Assets data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Jira Assets. To access Jira Assets data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Jira Assets.
Once you have acquired the necessary connection properties, accessing Jira Assets data in PowerShell can be enabled in three steps.
Jira Assets supports connecting and authenticating via the APIToken.
To generate an API token:
Atlassian generates and then displays the API token.
After you have generated the API token, set these parameters:
You are now ready to connect and authenticate to Jira Assets.
Install the module:
Install-Module JiraAssetsCmdlets
Connect:
$jiraassets = Connect-JiraAssets -User "$User" -APIToken "$APIToken" -Url "$Url"
Search for and retrieve data:
$label = "SYD-1" $objects = Select-JiraAssets -Connection $jiraassets -Table "Objects" -Where "Label = `'$Label`'" $objects
You can also use the Invoke-JiraAssets cmdlet to execute SQL commands:
$objects = Invoke-JiraAssets -Connection $jiraassets -Query 'SELECT * FROM Objects WHERE Label = @Label' -Params @{'@Label'='SYD-1'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Jira Assets\lib\System.Data.CData.JiraAssets.dll")
Connect to Jira Assets:
$conn= New-Object System.Data.CData.JiraAssets.JiraAssetsConnection("User=MyUser;APIToken=myApiToken;Url=https://yoursitename.atlassian.net")
$conn.Open()
Instantiate the JiraAssetsDataAdapter, execute an SQL query, and output the results:
$sql="SELECT ID, Name from Objects"
$da= New-Object System.Data.CData.JiraAssets.JiraAssetsDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.id $_.name
}
Update-JiraAssets -Connection $JiraAssets -Columns @('ID','Name') -Values @('MyID', 'MyName') -Table Objects -Id "MyId"
$cmd = New-Object System.Data.CData.JiraAssets.JiraAssetsCommand("UPDATE Objects SET Label='SYD-1' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.JiraAssets.JiraAssetsParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Add-JiraAssets -Connection $JiraAssets -Table Objects -Columns @("ID", "Name") -Values @("MyID", "MyName")
$cmd = New-Object System.Data.CData.JiraAssets.JiraAssetsCommand("INSERT INTO Objects (Label) VALUES (@myLabel)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.JiraAssets.JiraAssetsParameter("@myLabel","SYD-1")))
$cmd.ExecuteNonQuery()
Remove-JiraAssets -Connection $JiraAssets -Table "Objects" -Id "MyId"
$cmd = New-Object System.Data.CData.JiraAssets.JiraAssetsCommand("DELETE FROM Objects WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.JiraAssets.JiraAssetsParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the Jira Assets Data Provider to get started:
Download NowLearn more:
👁 Jira Assets IconRapidly create and deploy powerful .NET applications that integrate with Jira Assets.