> For the complete documentation index, see [llms.txt](https://help.autify.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.autify.com/nocode-web/autify-university/integrations/gitlab-cicd-integration.md). Agents can also search and read this documentation through its [MCP server](https://help.autify.com/~gitbook/mcp).

# GitLab CI/CD 連携

Autify ではお手持ちのGitLab CI/CD workflow から簡単にテストプランやシナリオを実行できる公式の手法を提供しています。

## はじめてみよう

このドキュメントでは、皆さんのGitLab リポジトリでどのようにGitLab CI/CD 連携を利用するかを順に説明していきます。

### 前提条件

まず、すでにGitLab CI/CD workflow を使ってステージングやプロダクション等へのソフトウェアのデプロイを行なっているものとします。そのデプロイjob のすぐ後にAutify のテストを実行するjob を追加することで、新しくデプロイされたソフトウェアがエンドツーエンドのユーザ体験を損ねていないことを確認できるようにします。

次に、[Autify NoCode Web](https://app.autify.com) でテストプランかテストシナリオを作成する必要があります。テストシナリオは、そのGitLab CI/CD workflow でソフトウェアがデプロイされるウェブサイトに対してレコーディングすることになります。テストプランまたはシナリオのURL (例: `https://app.autify.com/projects/00/scenarios/000`) をメモしておいてください、後ほど利用します。

さらに、[パーソナルアクセストークンを生成する](https://help.autify.com/nocode-web/autify-university/integrations/integrate-with-api.md#issue-a-personal-access-token)必要があります。後ほどGitLab CI/CD variables に保存するために、生成されたトークンはどこかにメモしておいて下さい。

*注: パーソナルアクセストークンは1人のユーザに紐づいてしまうので、CI/CD 連携のために組織にマシンユーザを作って、そのパーソナルアクセストークンを使うことをお勧めします。*

### パーソナルアクセストークンをGitLab CI/CD variables に保存

上で生成したパーソナルアクセストークンを[GitLabのドキュメント](https://docs.gitlab.com/ee/ci/variables/index.html#add-a-cicd-variable-to-a-project)に従って、Custon CI/CD variables としてVariables に保存します。(project またはgroup に保存します。) もしprotected でないbranch/tag に対してAutify のjob を実行したければ、"Protect variable" の選択を解除します。万が一トークンの値がログに曝露しないように、"Mast variable" を選択しておくことをお勧めします。

**この値は絶対に`.gitlab-ci.yml` に直接保存してはいけません。平文で読むことが可能になってしまいます。**

Variable のkey は任意ですが、`AUTIFY_WEB_ACCESS_TOKEN` と命名した場合はそれがAutify CLI が読み込むデフォルトの変数なので、後ほどこのkey を指定する必要がありあせん。ここではそうしたと仮定しておきます。

### Autify NoCode Web を実行するGitLab CI/CD job を追加

それでは、お手持ちのGitLab CI/CD workflow に新しいjob を追加しましょう。お手持ちの`.gitlab-ci.yml` を開き、以下の例を参考にしてください。URL の値(`https://app.autify.com/projects/00/scenarios/000`)は上でメモしたURL になります。

***

シンプルにテストを開始してstep を終了 (テストの完了は待たない):

```yaml
autify-test-job:
  stage: <YOUR_STAGE>
  before_script:
    - curl https://autify-cli-assets.s3.amazonaws.com/autify-cli/channels/stable/install-standalone.sh | sh
  script:
    - autify web test run https://app.autify.com/projects/00/scenarios/000
```

テストを開始して、それが完了するかタイムアウトするまで待つ:

```yaml
autify-test-job:
  stage: <YOUR_STAGE>
  before_script:
    - curl https://autify-cli-assets.s3.amazonaws.com/autify-cli/channels/stable/install-standalone.sh | sh
  script:
    - autify web test run https://app.autify.com/projects/00/scenarios/000 --wait --timeout 300
```

**警告: この設定はテスト完了を待っている間もGitLab CI/CD minites を消費します。タイムアウトを延長するときは注意してください。**

`--url-replacements` を使ってテストプラン又はシナリオを別のURL に対して開始する:

```yaml
autify-test-job:
  stage: <YOUR_STAGE>
  before_script:
    - curl https://autify-cli-assets.s3.amazonaws.com/autify-cli/channels/stable/install-standalone.sh | sh
  script:
    - autify web test run https://app.autify.com/projects/00/scenarios/000 --url-replacements http://example.com=http://example.net
```

`--url-replacements` はステージングのウェブサイトに対してプロダクションのウェブサイトで記録したテストシナリオを実行したい時などに有効です。

## まとめ

Autify のGitLab CI/CD 連携を使うことで、デプロイ後にテストプランやシナリオの実行を自動化できるので、無駄な時間を使うことなくリグレッションをすぐに検知して適切な行動を取ることができるようになります。


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.autify.com/nocode-web/autify-university/integrations/gitlab-cicd-integration.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
