Powershell からの Jira Service Desk データ連携タスクを自動化

PowerShell から Jira Service Desk に簡単に接続する方法をお探しですか? CData ADO.NET Provider for JiraServiceDesk は、PowerShell スクリプトの優位性を使い、シンプルで簡単に使えるADO.NET インターフェース を提供します。PowerShell スクリプトで、ADO.NET オブジェクトを使って簡単にJira Service Desk に接続して、同期、自動化、ダウンロードなどが可能!

加藤龍彦
ウェブデベロッパー


こんにちは!ウェブ担当の加藤です。マーケ関連のデータ分析や整備もやっています。



CData ADO.NET Provider for JiraServiceDesk は、ADO.NET 標準インターフェースへ統合し、PowerShell のような. NET アプリケーションからJira Service Desk API へのデータ連携を可能にします。このプロバイダーは、Jira Service Desk の認証および相互作用を簡単にします。このチュートリアルでは、PowerShell から直接SQL クエリを実行するための、いくつかの一般的なADO.NET オブジェクトの使い方を説明します。

クエリの実行

次の3つのステップに従って create、read、update、およびdelete (CRUD) のデータ連携コマンドを PowerShell からリアルタイムJira Service Desk に実行:

  1. プロバイダーのアセンブリをロード:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for JiraServiceDesk\lib\System.Data.CData.JiraServiceDesk.dll")
  2. Jira Service Desk に接続:

    You can establish a connection to any Jira Service Desk Cloud account or Server instance.

    Connecting with a Cloud Account

    To connect to a Cloud account, you'll first need to retrieve an APIToken. To generate one, log in to your Atlassian account and navigate to API tokens > Create API token. The generated token will be displayed.

    Supply the following to connect to data:

    • User: Set this to the username of the authenticating user.
    • APIToken: Set this to the API token found previously.

    Connecting with a Service Account

    To authenticate with a service account, you will need to supply the following connection properties:

    • User: Set this to the username of the authenticating user.
    • Password: Set this to the password of the authenticating user.
    • URL: Set this to the URL associated with your JIRA Service Desk endpoint. For example, https://yoursitename.atlassian.net.

    Note: Password has been deprecated for connecting to a Cloud Account and is now used only to connect to a Server Instance.

    Accessing Custom Fields

    By default, the connector only surfaces system fields. To access the custom fields for Issues, set IncludeCustomFields.

    $constr = "ApiKey=myApiKey;User=MyUser;" $conn= New-Object System.Data.CData.JiraServiceDesk.JiraServiceDeskConnection($constr) $conn.Open()
  3. JiraServiceDeskDataAdapter のインスタンスを生成してSQL クエリを実行し、結果を出力:

    $sql="SELECT RequestId, ReporterName from Requests" $da= New-Object System.Data.CData.JiraServiceDesk.JiraServiceDeskDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.requestid $_.reportername }

Jira Service Desk データの更新

$cmd = New-Object System.Data.CData.JiraServiceDeskCommand("UPDATE Requests SET CurrentStatus='Open' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.JiraServiceDeskParameter("myId","10456255-0015501366")) $cmd.ExecuteNonQuery()

Jira Service Desk へのデータの挿入

$cmd = New-Object System.Data.CData.JiraServiceDeskCommand("UPDATE Requests SET CurrentStatus='Open' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.JiraServiceDeskParameter("myId","10456255-0015501366")) $cmd.ExecuteNonQuery()

Jira Service Desk データの削除

$cmd = New-Object System.Data.CData.JiraServiceDeskCommand("UPDATE Requests SET CurrentStatus='Open' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.JiraServiceDeskParameter("myId","10456255-0015501366")) $cmd.ExecuteNonQuery()

関連コンテンツ

トライアル・お問い合わせ

30日間無償トライアルで、CData のリアルタイムデータ連携をフルにお試しいただけます。記事や製品についてのご質問があればお気軽にお問い合わせください。