> 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/kdosukyan/local-code-scanning/teamcity-pipeline-setup-for-local-code-scanning.md).

# ローカルコードスキャン用のTeamCityパイプライン設定

既定では、Aikidoはクラウド上でリポジトリをスキャンできます。コードへのアクセスを共有したくない場合は、ローカルスキャンオプションを使用できます。Aikido Security Local Scannerは、Aikido Securityのスキャンをお使いの環境内、ここではTeamCity Pipelines内で実行できるようにするツールです。スキャンはパイプライン内で行われ、その結果はAikido Securityプラットフォームにアップロードされます。

## ローカルスキャンの設定方法 <a href="#how-to-set-up-local-scanning" id="how-to-set-up-local-scanning"></a>

**前提条件**: ローカルスキャンを許可するアカウントを作成しておいてください。 [ローカルスキャンアカウントの作成に関する詳細](https://help.aikido.dev/en/articles/9070345-how-to-create-an-account-for-local-scanning-on-aikido).

### 1. 認証トークンを取得する <a href="#id-1-get-your-authentication-token" id="id-1-get-your-authentication-token"></a>

1. 次へ移動します [ローカルスキャナーのセットアップページ](https://app.aikido.dev/settings/integrations/localscan).
2. 認証トークンを生成してコピーします。このトークンは一度しか表示できないことに注意してください。
3. このトークンを引数として追加 `--apikey` プロジェクトで Local Scanner を実行する際に使用します。
4. このトークンをパイプラインのシークレットとして保存してください。

   ![APIキーをシークレットとして安全に追加するためのアプリ設定画面。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-644840b12615e38905621806e76c723f5a445ec1%2Fucarecdn-9ba9b826-ae28-47cf-b61a-39381cc387ef.png?alt=media)

### 2. Local Scanner の実行 <a href="#id-2-running-the-local-scanner" id="id-2-running-the-local-scanner"></a>

これで残るのは、リポジトリでスキャナーを実行することだけです。\
​\
ローカルスキャナーは、必ずデフォルトブランチでのみ起動するようにしてください。既定では、Aikidoはリポジトリ内の1つのブランチについて、依存関係とコードの問題をスキャンできます。通常はmainまたはmasterブランチです。そのため、Aikidoプラットフォーム上でスキャン結果が混在しないよう、ローカルスキャナーはそのブランチのみに対して実行することを推奨します。これはパイプラインの設定時に指定できます。

### Docker を使用する <a href="#using-docker" id="using-docker"></a>

TeamCity パイプラインでローカルスキャナーを使用する最も簡単な方法は、Dockerイメージを使うことです。\
​\
YAMLの例：

```yaml
jobs:
  ジョブ1:
    name: Aikido Scan
    steps:
      - type: スクリプト
        name: Aikidoスキャンを実行
        docker-image: aikidosecurity/local-scanner
        script-content: >-
          aikido-local-scanner scan ./ --apikey %AIKIDO_API_KEY%
          --repositoryname MyRepo --branchname main
    runs-on: Linux-Medium
```

お好みのブランチを指定するには、 `--branchname` をコマンド実行時に使用します。

このリポジトリで最初のスキャンの場合、Aikido は指定した名前でリポジトリを作成し、すべてのスキャン結果をそこに含めます。以降のスキャン結果は、Aikido ではこのリポジトリ名の下に集約されます。

デフォルトではすべてのスキャンタイプが実行されます。選択したスキャンのみ（例: SAST のみ）を実行したい場合は、 `--scan-types` オプション。CLI オプションの詳細は [こちら](https://help.aikido.dev/en/articles/9027526-local-scanner-cli-options).

を指定することで可能です。リリースゲーティングモードや PR ゲーティングモードでもスキャナーを実行できます。リリース前にリポジトリをスキャンする場合、潜在的なリリース前に未解決の問題がないことを確認できるため、リリースゲーティングモードは有用です。リリースゲーティングモードで実行すると、スキャン完了後に選択した重大度以上の未解決の問題が存在する場合、スキャナープロセスは失敗します。PR ゲーティングモードは、PR 内で新たに導入された可能性のある問題をスキャンするために使用できます。

リリースまたは PR ゲーティングモードの詳細は、 [この記事](/docs/docs-ja/kdosukyan/local-code-scanning/pr-gating-for-code-using-local-scanner.md).

### 3. スキャン結果を確認する <a href="#id-3-check-your-scanning-results" id="id-3-check-your-scanning-results"></a>

最初のスキャンが完了したら、Aikido Feed で結果を確認できます。指定した名前のリポジトリが作成され、スキャン結果がすべて含まれます。


---

# 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/kdosukyan/local-code-scanning/teamcity-pipeline-setup-for-local-code-scanning.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.
