--- title: "Autify Jenkins 連携ガイド | Autify Guide" slug: "jenkins-integration" description: "AutifyをJenkinsと連携する方法を学びましょう。シームレスな自動化テストを開始しましょう!" updated: 2024-07-17T13:24:15Z published: 2024-07-17T13:24:15Z canonical: "help.autify.com/jenkins-integration" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.autify.com/llms.txt > Use this file to discover all available pages before exploring further. # Jenkins 連携 Autify ではお手持ちのJenkins workflow から簡単にテストプランやシナリオを実行できる[公式のJenkins plugin](https://plugins.jenkins.io/autify/) を提供しています。 ## はじめてみよう このドキュメントでは、どのように[Autify Jenkins plugin](https://plugins.jenkins.io/autify/) を利用するかを順に説明していきます。 ### 前提条件 まず、すでにJenkins Project やPipeline を使ってステージングやプロダクション等へのソフトウェアのデプロイを行なっているものとします。そのデプロイstep のすぐ後にAutify のテストを実行するstep を追加することで、新しくデプロイされたソフトウェアがエンドツーエンドのユーザ体験を損ねていないことを確認できるようにします。 次に、[Autify NoCode Web](https://app.autify.com) でテストプランかテストシナリオを作成する必要があります。テストシナリオは、そのJenkins でソフトウェアがデプロイされるウェブサイトに対してレコーディングすることになります。テストプランまたはシナリオのURL (例: `https://app.autify.com/projects/00/scenarios/000`) をメモしておいてください、後ほど利用します。 さらに、[パーソナルアクセストークンを生成する](https://help.autify.com/docs/ja/integrate-with-api#%E3%83%91%E3%83%BC%E3%82%BD%E3%83%8A%E3%83%AB%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E3%83%88%E3%83%BC%E3%82%AF%E3%83%B3%E3%81%AE%E7%99%BA%E8%A1%8C)必要があります。後ほどJenkins Secrets に保存するために、生成されたトークンはどこかにメモしておいて下さい。 パーソナルアクセストークン パーソナルアクセストークンは1人のユーザに紐づいてしまうので、CI/CD 連携のために組織にマシンユーザを作って、そのパーソナルアクセストークンを使うことをお勧めします。 ### Plugin をインストールする [Autify Plugin のページ](https://plugins.jenkins.io/autify/) を開き、右上の"How to install" をクリックします。以下の様なインストールの選択肢が表示されます: ![Screen Shot 2022-08-12 at 9.46.25 AM.png](https://cdn.document360.io/a099d8a2-cfd2-42ca-9906-68b4a337f4a5/Images/Documentation/Screen%20Shot%202022-08-12%20at%209.46.25%20AM.png?sv=2026-02-06&spr=https&st=2026-11-06T21%3A49%3A58Z&se=2026-11-06T22%3A49%3A58Z&sr=c&sp=r&sig=oHO15wY%2FLC9nZBk0G8ueKAnXrKe8h%2FtgTz2Xv%2BExH0o%3D) ### パーソナルアクセストークンをJenkins Secrets に保存 上で生成したパーソナルアクセストークンを[Jenkins のドキュメント](https://www.jenkins.io/doc/book/using/using-credentials/)に従って、Secrets に保存します。"Kind" には **"Secret text" を使って**、"ID" には任意の名前を付けられます。ここでは`autifyWebAccessToken` と命名したと仮定しておきます: ![Screen Shot 2022-08-08 at 5.05.04 PM.png](https://cdn.document360.io/a099d8a2-cfd2-42ca-9906-68b4a337f4a5/Images/Documentation/Screen%20Shot%202022-08-08%20at%205.05.04%20PM.png?sv=2026-02-06&spr=https&st=2026-11-06T21%3A49%3A58Z&se=2026-11-06T22%3A49%3A58Z&sr=c&sp=r&sig=oHO15wY%2FLC9nZBk0G8ueKAnXrKe8h%2FtgTz2Xv%2BExH0o%3D) ### Autify for Web を実行するbuild step を追加する それではお手持ちのJenkins Project またはPipeline に新しいstep を追加しましょう。 #### Jenkins Project お手持ちのProject のconfiguration に行き、"Build" の下にある"Add build step"をクリックし、"Run test on Autify for Web" を選択します: ![Screen Shot 2022-08-09 at 3.21.56 PM.png](https://cdn.document360.io/a099d8a2-cfd2-42ca-9906-68b4a337f4a5/Images/Documentation/Screen%20Shot%202022-08-09%20at%203.21.56%20PM.png?sv=2026-02-06&spr=https&st=2026-11-06T21%3A49%3A58Z&se=2026-11-06T22%3A49%3A58Z&sr=c&sp=r&sig=oHO15wY%2FLC9nZBk0G8ueKAnXrKe8h%2FtgTz2Xv%2BExH0o%3D) そうしたら、"Personal Access Token of Autify for Web" のセレクトボックスから上で作成したSecret のID (例: `autifyWebAccessToken`)を選択し、"Autify for Web test URL" には上で記録したURL (例: `https://app.autify.com/projects/00/scenarios/000`) を貼り付けます。 以下の例をご覧ください。 --- シンプルにテストを開始してstep を終了 (テストの完了は待たない): ![Screen Shot 2022-08-11 at 4.42.09 PM.png](https://cdn.document360.io/a099d8a2-cfd2-42ca-9906-68b4a337f4a5/Images/Documentation/Screen%20Shot%202022-08-11%20at%204.42.09%20PM.png?sv=2026-02-06&spr=https&st=2026-11-06T21%3A49%3A58Z&se=2026-11-06T22%3A49%3A58Z&sr=c&sp=r&sig=oHO15wY%2FLC9nZBk0G8ueKAnXrKe8h%2FtgTz2Xv%2BExH0o%3D) テストを開始して、それが完了するかタイムアウトするまで待つ - "Wait?" をチェックします: ![Screen Shot 2022-08-12 at 12.06.03 AM.png](https://cdn.document360.io/a099d8a2-cfd2-42ca-9906-68b4a337f4a5/Images/Documentation/Screen%20Shot%202022-08-12%20at%2012.06.03%20AM.png?sv=2026-02-06&spr=https&st=2026-11-06T21%3A49%3A58Z&se=2026-11-06T22%3A49%3A58Z&sr=c&sp=r&sig=oHO15wY%2FLC9nZBk0G8ueKAnXrKe8h%2FtgTz2Xv%2BExH0o%3D) "URL replacements" を使ってテストプラン又はシナリオを別のURL に対して開始する - "Advanced" をクリックし"URL replacements" の"Add" をクリックします: ![Screen Shot 2022-08-12 at 12.06.38 AM.png](https://cdn.document360.io/a099d8a2-cfd2-42ca-9906-68b4a337f4a5/Images/Documentation/Screen%20Shot%202022-08-12%20at%2012.06.38%20AM.png?sv=2026-02-06&spr=https&st=2026-11-06T21%3A49%3A58Z&se=2026-11-06T22%3A49%3A58Z&sr=c&sp=r&sig=oHO15wY%2FLC9nZBk0G8ueKAnXrKe8h%2FtgTz2Xv%2BExH0o%3D) *"URL replacements" はステージングのウェブサイトに対してプロダクションのウェブサイトで記録したテストシナリオを実行したい時などに有効です。* #### Jenkins Pipeline お手持ちの`Jenkinsfile` またはPipeline のconfiguration ページを開き、以下の様なstep をデプロイのstep の直後に追加します。 --- シンプルにテストを開始してstep を終了 (テストの完了は待たない): ``` autifyWeb credentialsId: 'autifyWebAccessToken', autifyUrl: 'https://app.autify.com/projects/00/scenarios/000' ``` テストを開始して、それが完了するかタイムアウトするまで待つ: ``` autifyWeb credentialsId: 'autifyWebAccessToken', autifyUrl: 'https://app.autify.com/projects/00/scenarios/000', wait: true ``` `urlReplacements` を使ってテストプラン又はシナリオを別のURL に対して開始する: ``` autifyWeb credentialsId: 'autifyWebAccessToken', autifyUrl: 'https://app.autify.com/projects/00/scenarios/000', urlReplacements: [[patternUrl: 'http://example.com', replacementUrl: 'http://example.net']] ``` *`urlReplacements` はステージングのウェブサイトに対してプロダクションのウェブサイトで記録したテストシナリオを実行したい時などに有効です。* ### (非推奨) "Execute shell" step を利用 **もしAutifyが提供する Jenkins plugin を利用したくないか、plugin に問題がある場合は、代わりに"Execute shell" step を利用することができます。** 以下に手順をまとめています: 1. もしまだであれば、以下のplugin をインストールします: - [Credentials](https://plugins.jenkins.io/credentials/) - [Plain Credentials](https://plugins.jenkins.io/plain-credentials/) - [Credentials Binding](https://plugins.jenkins.io/credentials-binding/) 2. パーソナルアクセストークンを上に書いてあるように保存します。 3. "Execute shell" build step を追加します: - Jenkins Project: ``` curl https://autify-cli-assets.s3.amazonaws.com/autify-cli/channels/stable/install-cicd.bash | bash -xe ./autify/bin/autify web test run https://app.autify.com/projects/00/scenarios/000 ``` 1. Secret を"Build Environment" > "Bindings" に追加します ("Variable" には`AUTIFY_WEB_ACCESS_TOKEN` を使います) 2. "Execute shell" build step を以下の様に追加します: - Jenkins Pipeline: ``` withCredentials([string(credentialsId: 'autifyWebAccessToken', variable: 'AUTIFY_WEB_ACCESS_TOKEN')]) { sh ''' curl https://autify-cli-assets.s3.amazonaws.com/autify-cli/channels/stable/install-cicd.bash | bash -xe ./autify/bin/autify web test run https://app.autify.com/projects/00/scenarios/000 ''' } ``` 1. `sh` を`withCredentials` で囲んで以下の様に追加します: 注: shell step 内のAutify CLI のコマンドはお好きな様にカスタマイズできます。詳しくは[Autify CLI のドキュメント](https://help.autify.com/docs/ja/autify-command-line-interface) をご覧ください。 ## まとめ [Autify のJenkins plugin](https://plugins.jenkins.io/autify/) (またはshell step)を使うことで、デプロイ後にテストプランやシナリオの実行を自動化できるので、無駄な時間を使うことなくリグレッションをすぐに検知して適切な行動を取ることができるようになります。