> For the complete documentation index, see [llms.txt](https://help.aikido.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.aikido.dev/docs/docs-ja/pr-torirsunogtingu/azure-pr-gating/azure-pipelines-setting-up-gating-for-pull-requests-via-code.md).

# Azure DevOps: コード経由でプルリクエストのゲーティングを設定

### 重要なお知らせ

{% hint style="danger" %}
この機能の使用はもう推奨しません。代わりに Aikido ダッシュボード経由の PR ゲーティングを使用してください。CI 分数を消費せず、一括管理がしやすく、ミスも起こりにくいためです。
{% endhint %}

### 導入

Aikido と Azure Pipelines の統合により、リスクのあるコードがマージされるのをフラグ付けまたはブロックできます。私たちの CI スキャンは対象とします **IaC**, **SAST**、および **依存関係の問題**.

Aikido Pro プランをご利用の場合、この統合を次の用途にも使用できます [CIゲーティング](https://help.aikido.dev/en/articles/7945775-setting-up-feature-branch-scanning).

> 注: この統合は TFVC リポジトリでは利用できません。

## 連携を設定 <a href="#set-up-integration" id="set-up-integration"></a>

**手順1。** 私たちの [CI 連携ページ](https://app.aikido.dev/settings/integrations/continuous-integration).

**手順2。** 認証トークンを生成します。連携のために、このトークンをCI環境で公開する必要があります。この手順でトークンを必ずコピーしてください。

**手順3。** Azure Pipelines をクリックします。Aikido Azure Extension ページにリダイレクトされます

![GitHub、GitLab、Bitbucket、Azure などの CI ツールを統合して、リスクのあるコードのマージをブロックします。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-0bc70b698c67da7b7078756ca3cf516c60b6d2bc%2Fucarecdn-8787fd95-f430-4ceb-9a6a-2e9c085d81fe.png?alt=media)

## 拡張機能をインストールする <a href="#install-the-extension" id="install-the-extension"></a>

緑色の「Get it free」ボタンをクリックします

![Aikido Security Scanner: セキュリティスキャン用の無料 Azure Pipelines 統合ツール。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-0c0eaae03f2a7360bede021414c17d09691fea9d%2Fucarecdn-e1fd7298-e234-4057-8943-57499e60f98d.png?alt=media)

拡張機能をインストールしたい組織を選択し、インストールをクリックします

![プライベート拡張機能をインストールする Azure DevOps 組織を選択します。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-ef7687adc6aa01b2ca6d98d78d837873846c9c44%2Fucarecdn-6efd326d-b1e8-418e-a951-b29c06ca06c1.png?alt=media)

拡張機能はインストールされました。Azure 組織の「Organisation Settings > Extensions」に移動して確認できます

![Aikido Security Scanner 拡張機能が Azure DevOps の組織設定にインストールされました。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-2e08f715948fd22980c7a252f13d4470a656de19%2Fucarecdn-d2df10f4-1aa6-4e57-8f3c-687214412530.png?alt=media)

## PR 用のパイプラインを設定する <a href="#set-up-the-pipeline-for-prs" id="set-up-the-pipeline-for-prs"></a>

これ専用に別のパイプラインを作成することを推奨しますが、既存のビルドにも統合できます

Pipelines に移動し、新しい Azure パイプラインを作成します。構成ステップで「Starter pipeline」を選択します

![さまざまな Node.js プロジェクトテンプレートとデプロイオプションのパイプライン構成オプション。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-38acccc893daaa10eb940d381c0be5e80e292b44%2Fucarecdn-cd05ea44-e92e-485a-b9f8-6923a4e03341.png?alt=media)

yml ファイルには次の内容を使用します。

```
pool:
  vmImage: ubuntu-latest
steps:
  - task: AikidoScanTask@1 
    inputs: 
      secretKey: $(AIKIDO_SECRET) 
      minimumSeverity: 'LOW'
      failOnDependencyScan: true
      failOnSastScan: false
      failOnIacScan: false
      failOnTimeout: true
      timeoutSeconds: 180
```

secretKey については、secretKey が公開されないように変数を使用することを推奨します。

AIKIDO\_SECRET 用の新しい変数を追加します。これは以前 Aikido アプリで生成したトークンです。

Variables ボタンをクリックします。

![変数の編集と「Save and run」オプションがあるパイプライン YAML の確認画面。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-b840d6a9adb39c5fd748acf4b22dd4876d20be9d%2Fucarecdn-d440d9d8-440a-4e85-9aab-86e8da0dbfd7.png?alt=media)

プラスアイコンのボタンをクリックします。

![検索バーと新しい変数を追加するボタンがある Variables パネル。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-556577027d56752832879c8a561c5b2e7edb936e%2Fucarecdn-f9adf410-9c08-4a7b-8638-76c4c89faf69.png?alt=media)

変数名を「AIKIDO\_SECRET」にします。値は以前 Aikido アプリで生成したトークンにします。このシークレットを完全に保護するには、「Keep this value secret option」をオンにします。変数を保存するには「OK」をクリックします。

![CI/CD パイプラインの設定ダイアログでシークレット環境変数を構成しています。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-59492ce048ea2867f7e8f85660cc7d96b4f5a768%2Fucarecdn-6a107e4a-5cb0-478f-92a6-dc995520276c.png?alt=media)

入力セクションには必須項目がいくつかあります。

* **secretKey:** これは生成されたトークンです **step2** の [連携を設定](https://help.aikido.dev/en/articles/9099968-setting-up-gating-for-pull-requests-with-azure-pipelines#h_1a95ad3e70)。これをパイプラインの ENV 変数に保存することを推奨します。
* **minimumSeverity:** この重大度の問題が見つかった場合、パイプラインは失敗する必要があります。使用可能なオプションは「LOW」「MEDIUM」「HIGH」および「CRITICAL」です

いくつかの任意項目は次のとおりです:

* **failOnDependencyScan:** 依存関係スキャンでスキャンを失敗させるかどうかを決定するブール値です。既定値は false です
* **failOnSastScan:** SAST スキャンでスキャンを失敗させるかどうかを決定するブール値です。既定値は false です
* **failOnIacScan:** IaC スキャンでスキャンを失敗させるかどうかを決定するブール値です。既定値は false です
* **timeoutSeconds:** タスクをいつ停止するかを決定する整数値です: 既定値は 180 です
* **failOnTimeout:** タイムアウト時にスキャンを失敗させるかどうかを決定するブール値です。既定値は false です

パイプラインを保存して実行します。

パイプラインが Azure Pipelines に表示されたら、「Branches」に移動し、スキャンを実行したい PR の対象ブランチに対して「Branch policies」を選択します。

![ブランチ選択、ポリシー、セキュリティオプションが表示されたブランチ概要インターフェース。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-8a1563cf258b07ec2dc4e3206edbeb13c6c8193a%2Fucarecdn-25e06f66-3bf0-4cfa-a2bd-890e9a864940.png?alt=media)

Build Validation に移動し、追加アイコンをクリックします

![ポリシーがない Build Validation 設定パネル。新しいポリシーの追加を促しています。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-887b8221b12bd78dd176c6b72477d1fe441b9eaf%2Fucarecdn-58ab5e0c-f40e-4906-bea5-f68cb4824a3b.png?alt=media)

新しい Aikido Scan パイプラインを選択します。希望のオプションを入力し、このビルドポリシーに表示名を必ず付けます。

![aikidoDev パイプライン「Aikido Scan」に対して、自動必須ビルドポリシーを設定しています。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-fb584ec8caaf715985f98575ac8b72c0631bf164%2Fucarecdn-353f1374-3eaf-4b95-8561-c004feabb423.png?alt=media)

Aikido は今後、対象ブランチがこのブランチである新しい PR をスキャンします。これは複数のブランチに対して設定できます

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.aikido.dev/docs/docs-ja/pr-torirsunogtingu/azure-pr-gating/azure-pipelines-setting-up-gating-for-pull-requests-via-code.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
