IBM Cloud Docs
DevSecOps CLI

DevSecOps CLI

DevSecOpsCLIは、以下のコンプライアンスソリューションを採用しています。IBM Cloud®DevSecOps参照実装。たとえば、シフトレフト参照パイプラインなど。 シフト・レフトのコンプライアンス・アーキテクチャーについて詳しくは、Continuous Delivery による DevSecOps を参照してください。

CLI インターフェース

CLI は、コマンド行でマルチパート構造を使用します。これは、以下の順序で指定する必要があります。

cocoa <command> <subcommand> [options]
  1. この CLI の基本の呼び出し。

  2. メインコマンド。通常、シフトレフトアーキテクチャで使用されるサービスまたはモジュールに対応する。

  3. 実行する操作を指定するサブコマンド。

  4. 操作に必要な CLI オプション。 ステップ 1 から 3 に従うことを条件として、CLI オプションを任意の順序で指定できます。

一部のコマンドは、APIキーを取得するため、またはコマンドラインで提供されなかったオプション値を設定するために、環境変数を使用する。 コマンドを実行する前に、これらの変数をエクスポートする必要がある。

コマンドラインオプションは、数値、文字列、ブール値、配列、JSONオブジェクトなど、さまざまなタイプの入力値を取ることができる。 オプションの種類は、指定するコマンドに依存する。 オプションの種類を見るには cocoa <command> <subcommand> --help を使ってください。

失敗した API 呼び出しの再試行

Cocoa CLI は、応答状況 5xx で失敗した API 呼び出しを 3 回再試行します。 この動作をオーバーライドするには、以下の環境変数を指定します。

  • MAX_RETRY_ATTEMPTS-Cocoa CLI が試行を中止するまでの再試行回数。 例えば、MAX_RETRY_ATTEMPTS=5 となる
  • RETRY_STATUS_CODE-再試行が行われる応答状況コード。 例えば、 RETRY_STATUS_CODE=409,422,500 と指定すると、これら 3 つの状況コードで再試行します。
export MAX_RETRY_ATTEMPTS=5                 # Retry API calls 5 times.
export RETRY_STATUS_CODE=409,422,500            # Retry API calls for response codes 409, 422 and 500.

再試行の間隔は指数関数的に長くなるため、再試行の間隔を大きくすると、再試行の間隔がさらに長くなります。

コマンド実行の経過時間

Cocoa CLI は、以下のように DISPLAY_ELAPSED_TIME を空でないストリングに設定することにより、任意のコマンドの経過時間を秒単位で表示できます。

export DISPLAY_ELAPSED_TIME=1`                # Display a snippet showing the total execution time of the cli command, example `Elapsed time: 5.32 seconds`

CLI コマンド

それでもServiceNow文書化されているが、デフォルトではサポートされていないIBM CloudDevSecOpsリファレンス実装。 しかし、使用方法を学びたい場合はServiceNowとともにDevSecOpsリファレンス実装、ヘルプの取得IBM Cloud開発チームに参加して スラック

cocoa pull 要求コマンド

cocoa check pull-request-approval

コミットハッシュの Pull Request の承認状態をチェックします。 プルリクエストが承認されなかった場合、指定されたリポジトリに新しいインシデント課題が作成されます。 このコマンドは、ラベル付きの緊急プル要求を識別できます。この場合、コマンドの終了コードは 0 です。

必要な環境変数:

GHE_TOKEN=              # Github Enterprise API Token (Optional if you are using --git-token-path field)
GHE_ORG=                # The owner of the repository
GHE_REPO=               # The repository name
INCIDENT_ISSUE_REPO=    # The incident issue repo name
EMERGENCY_LABEL=        # Emergency Label name
GIT_COMMIT=             # Commit hash of the Pull Request

オプション:

--label                 # Label to add to possible pr incident issue
--git-provider          # SCM provider (GitHub)
--git-token-path        # (Optional) GitHub Token's path
--git-api-url           # (Optional) GitHub API url

使用している場合GitHub,使用できます --git-token-path 設定するフィールドGitHubトークンと --git-api-url#を設定するフィールドGitHub EnterpriseAPI URLの代わりに GHE_TOKEN そして GH_URL 環境変数。 両方が指定されている場合は、 --git-token-path--git-api-url が優先されます。

次のコマンドを実行します。

cocoa check pull-request-approval

cocoa check pull-request-status

指定されたプル要求の状況とリポジトリーの設定を検査します。

  • ブランチの保護: 強制プッシュを無効にし、ブランチの削除を禁止し、オプションでマージの前の状況検査を必須にするルール。
  • コミットステータスチェック: コミットに errorfailurependingsuccess の状態をつける外部サービス。
  • 検査の実行: 継続的統合、コード・リンティング、またはコード・スキャンのサービスを実行し、コミットに関する詳細なフィードバックを提供するアプリ。

必要な環境変数:

REQUIRED_CHECKS=        # Minimum required checks to be compliant set by client
GIT_BRANCH=             # Branch name for branch protection check
GIT_COMMIT=             # Commit hash of the Pull Request
GHE_TOKEN=              # Github Enterprise API Token (Optional if you are using --git-token-path field)
GHE_ORG=                # The owner of the repository
GHE_REPO=               # The repository name

使用している場合GitHub,使用できます --git-token-path 設定するフィールドGitHubトークンと --git-api-url#を設定するフィールドGitHub EnterpriseAPI URLの代わりに GHE_TOKEN そして GH_URL 環境変数。 GHE_TOKEN GH_URL--git-token-path --git-api-url の両方のペアが指定されている場合は、 --git-token-path--git-api-url が優先されます。

REQUIRED_CHECKS 例:

  [
    {
      "type": "status",
      "name": "unit-test",
      "params": {
        "name": "travis/ci"
      }
    },
    {
      "type": "check-run",
      "name": "secret-detection",
      "params": {
        "name": "detect-secrets"
      }
    },
    {
      "type": "branch-protection",
      "name": "code review",
      "params": {
        "checks": ["travis/ci", "detect-secrets"]
      }
    },
    {
      "type": "check-run",
      "name": "open-source-license-scan",
      "params": {
        "name": "ossc/ci"
      }
    }
  ]

次のコマンドを実行します。

 cocoa check pull-request-status

cocoa 変更要求コマンド

cocoa change-request コマンドは、以下の変更管理プロバイダーをサポートします。

  • ServiceNow V1
  • ServiceNow V3

servicenow (デフォルト) または servicenow-v3 を指定した --provider オプションを使用して、プロバイダーを指定できます。

プロバイダーごとに異なる環境変数構成が必要です。

  • servicenow:
    • SERVICENOW_TOKEN- ServiceNow V1 API トークン
    • SERVICENOW_URL- ServiceNow V1 API の URL
  • servicenow-v3:
    • PNP_IBMCLOUD_API_KEY- ServiceNow v3 エンドポイントにアクセスするための API キー (指定されていない場合) は、IAM_ACCESS_TOKEN にフォールバックします。
    • IAM_ACCESS_TOKEN-IBMCloud IAM OAuth トークン
    • SERVICENOW_URL- ServiceNow V3 API URL
  • github-enterprise:
    • GHE_TOKEN- GitHub Enterprise トークン
    • GITHUB_CHANGE_MANAGEMENT_REPO- GitHub 変更管理リポジトリー
    • GITHUB_CHANGE_MANAGEMENT_ORG- GitHub 変更管理組織

cocoa change-request get

ServiceNow APIから変更リクエストを照会し、ファイルに保存するかコンソールに出力します。

ServiceNow v1 または v2:

SERVICENOW_TOKEN= # ServiceNow API Token
SERVICENOW_URL=   # ServiceNow API URL

ServiceNow v3:

SERVICENOW_URL=       # ServiceNow API URL

ServiceNow v3:

PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN=     # Access token obtained from the IAM service

GitHub Enterpriseに必要な環境変数:

GHE_TOKEN=    # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG=   # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO=    # The repository name (optional, when --repo is not provided)

Gitlabに必要な環境変数

GITLAB_TOKEN= # Gitlab token. (Optional if you are using --git-token-path)
GITLAB_URL=   # Change management API URL (Optional if you are using --git-api-url)

オプション:

--change-request-id='CHGXXXXXX'  # (Required) The Change Request ID to query from ServiceNow.
--output='filename.json'         # (Optional) If provided, the Change Request data will be written to this file.
--provider='servicenow'          # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')

次のコマンドを実行します。

# Read Change Request with number 'CHG123456' and output the JSON Data to the console.
$ cocoa change-request get --change-request-id='CHG123456'

# Read Change Request with number 'CHG123456' and output the JSON Data to the file named 'cr.json'.
$ cocoa change-request get --change-request-id='CHG123456' --output='cr.json'

# Read Change Request with number 'CHG123456' using the ServiceNow v3 API
$ cocoa change-request get --change-request-id='CHG123456' --provider='servicenow-v3'

cocoa change-request create

変更要求を作成して ServiceNow API に送ります。

次の 2 つの使用方法があります。

  • 必要なすべての CR フィールドを CLI オプションから提供する。

オプション:

--assigned-to      # A ServiceNow validated user (defaults to value found in the pull request)
--system           # the name of the system in ServiceNow
--impact           # impact explanation (defaults to value found in th pull request)
--outage-duration  # duration of the outage (format: 'd HH:mm:ss' or 'none')
--priority         # change priority, valid options: critical, high, moderate, low, planning (defaults to value found in the pull request)
--environment      # the environment for the deployment
--purpose          # purpose explanation (default to value found in the pull request)
--description      # description of the change
--backout-plan     # description of the backout plan (defaults to the value found in the PR)
--planned-start    # planned start time of the change (required format: YYYY-MM-DD HH:mm:ss, e.g 2020-05-13 13:00:12, in UTC)
--planned-end      # planned end time of the change (required format: YYYY-MM-DD HH:mm:ss, e.g 2020-05-13 13:00:12, in UTC)
--deployment-ready # readiness for deployment (choices: 'yes', 'no', default: 'yes')
--type             # change request type, option: standard, emergency
--provider         # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', 'github-enterprise', 'gitlab' default: 'servicenow')
--pipeline-name    # (Optional) name of the pipeline used for identifying the pipeline
--pipeline-version # (Optional) version of pipeline used (value must match regular expression [0-9.]+)
  • 解析する変更要求データが含まれているファイル名を提供する。 JSON 形式である必要があります。

オプション:

--file --f         # json file name to parse the cr data from
--provider         # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')

ファイルの例:

{
  "type": "emergency",
  "assignedto": "alexandra.szanto@ibm.com",
  "backoutplan": "rollback",
  "priority": "critical",
  "purpose": "bugfix",
  "description": "test description",
  "environment": "crn:v1:bluemix:public::ch-ctu-2::::",
  "impact": "bug",
  "system": "devopsinsights",
  "outageduration": "0 00:00:00",
  "plannedstart": "2020-10-05 14:48:00",
  "plannedend": "2020-10-05 14:49:00",
  "deploymentready": "yes",
}

ServiceNow v1 または v2:

SERVICENOW_TOKEN=   # ServiceNow API Token
SERVICENOW_URL=     # ServiceNow API URL

ServiceNow v3:

SERVICENOW_URL=       # ServiceNow API URL

ServiceNow v3:

PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN=     # Access token obtained from the IAM service

GitHub Enterpriseに必要な環境変数:

GHE_TOKEN=    # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG=   # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO=    # The repository name (optional, when --repo is not provided)

次のコマンドを実行します。

 cocoa change-request create --file=test.json

それとも

$ cocoa change-request create \
  --assigned-to=<your-ibm-email> \
  --system=<servicenow-configuration-item> \
  --impact=<impact description> \
  --outage-duration='0 00:00:00' \
  --priority=<the-priority> \
  --environment=<involved-environment> \
  --purpose=<purpose-explanation> \
  --description=<description-of-the-change> \
  --backout-plan=<description-of-a-backout-plan> \
  --planned-start='2020-05-13 13:00:12' \
  --planned-end='2020-05-13 13:10:12' \
  --deployment-ready=<yes/no> \
  --type=<change-type> \

cocoa change-request change-state-to-implement

ServiceNow APIを通じて、変更要求の状態を implement に変更します。

オプション:

--provider         # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')

プロバイダーに関係なく必要な環境変数:

CHANGE_REQUEST_ID=  # ID of the Change Request

ServiceNow v1 または v2 プロバイダーを使用している場合に必要な環境変数:

SERVICENOW_TOKEN=    # ServiceNow API Token
SERVICENOW_URL=      # ServiceNow API URL

ServiceNow v3 プロバイダーを使用している場合の必須環境変数:

SERVICENOW_URL=       # ServiceNow API URL

追加の環境変数 ( ServiceNow v3 プロバイダーを使用している場合):

PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN=     # Access token obtained from the IAM service

GitHub Enterprise プロバイダーに必要な環境変数:

GHE_TOKEN=    # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG=   # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO=    # The repository name (optional, when --repo is not provided)

次のコマンドを実行します。

 cocoa change-request change-state-to-implement

cocoa change-request close

ServiceNow APIを通じて変更リクエストをクローズします。 --close-notes オプションを使って「クローズノート」を添付し、--close-category オプションを使って「クローズカテゴリー」を指定することができます。

オプション:

--close-category  # Choices: "successful" (default), "successful_issues", "unsuccessful", "cancelled"
--close-notes     # String, defaults to "Deployment done."
--provider        # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')

プロバイダーに関係なく必要な環境変数:

CHANGE_REQUEST_ID=  # ID of the Change Request

ServiceNow v1 または v2 プロバイダーを使用している場合に必要な環境変数:

SERVICENOW_TOKEN=    # ServiceNow API Token
SERVICENOW_URL=      # ServiceNow API URL

ServiceNow v3 プロバイダーを使用している場合の必須環境変数:

SERVICENOW_URL=       # ServiceNow API URL

追加の環境変数 ( ServiceNow v3 プロバイダーを使用している場合):

PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN=     # Access token obtained from the IAM service

GitHub Enterprise プロバイダーに必要な環境変数:

GHE_TOKEN=    # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG=   # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO=    # The repository name (optional, when --repo is not provided)

次のコマンドを実行します。

 cocoa change-request close

cocoa change-request check-approval

変更要求の承認ステータスを照会します。 変更要求が緊急の場合、コマンドは失敗しないが、遡及承認を求めるプロンプトが表示される。

オプション:

--provider         # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')

プロバイダーに関係なく必要な環境変数:

CHANGE_REQUEST_ID=  # ID of the Change Request

ServiceNow v1 または v2 プロバイダーを使用している場合に必要な環境変数:

SERVICENOW_TOKEN=    # ServiceNow API Token
SERVICENOW_URL=      # ServiceNow API URL

ServiceNow v3 プロバイダーを使用している場合の必須環境変数:

SERVICENOW_URL=       # ServiceNow API URL

追加の環境変数 ( ServiceNow v3 プロバイダーを使用している場合):

PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN=     # Access token obtained from the IAM service

GitHub Enterprise プロバイダーに必要な環境変数:

GHE_TOKEN=    # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG=   # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO=    # The repository name (optional, when --repo is not provided)

次のコマンドを実行します。

 cocoa change-request check-approval

cocoa change-request prepare

変更要求データを作成し、コンソールまたはファイルに出力します。

必要な環境変数:

GHE_TOKEN=              # Github Enterprise API Token (only required when parsing from pr)
GHE_ORG=                # The owner of the repository (optional, when --org is not provided)
GHE_REPO=               # The repository name (optional, when --repo is not provided)
EMERGENCY_LABEL=        # Emergency Label (optional, when --emergency-label is not provided)

次の各フィールドはプル要求の本文から解析できます。

--assigned-to
--impact
--priority
--purpose
--backout-plan
--type
--customer-impact
--deployment-impact

CLIオプションを使用して提供された場合、CLIオプションはプルリクエストにある値を上書きします。 これらすべてが提供されている場合、prは解析されず、--org--repoGHE_TOKEN は必要ありません。

オプション:

--org              # github organization where the parsed pr is (only needed if fields are parsed from pr, defaults to GHE_ORG)
--repo             # github repository name whre the parsed pr is (only needed if fields are parsed from pr, defaults to GHE_REPO)
--pr               # the pull request number to parse (mutually exclusive with sha and branch)
--sha              # infer the pr number from hash (mutually exclusive with pr and branch)
--branch           # infer PR based on the last merged pr into this branch (defaults to master)
--assigned-to      # A ServiceNow validated user (defaults to value found in the pull request)
--system           # the name of the system in ServiceNow
--impact           # implact explanation (defaults to value found in th pull request)
--outage-duration  # duration of the outage
--planned-start    # planned start time of the change (required format: YYYY-MM-DD HH:mm:ss, e.g 2020-05-13 13:00:12, in UTC)
--planned-end      # planned end time of the change (required format: YYYY-MM-DD HH:mm:ss, e.g 2020-05-13 13:00:12, in UTC)
--priority         # change priority, valid options: critical, high, moderate, low, planning (defaults to value found in the pull request)
--environment      # the environment for the deployment
--purpose          # purpose explanation (default to value found in the pull request)
--backout-plan     # description of the backout plan (defaults to the value found in the PR)
--deployment-ready # description of the change
--type             # change request type, option: standard, emergency
--emergency-label  # emergency label to look for in the pull request
--file             # file name to print the cr data to (optional, prints to stdout by default)
--service-environment # service environment of the change, valid options: production, pre_prod
--service-environment-detail # brief description of the service environment where change is deployed.
--pipeline-name    # (Required) name of the pipeline used (for example 'onepipeline | continuous-delivery')
--pipeline-version # version of pipeline used (for example '9.22.3')
--validation-record # Pre-prod change request numbers or NA if there is no pre-prod change request for the deployment

次のコマンドを実行します。

$ cocoa cr prepare \
  --org=<github-organization> \
  --repo=<github-repo-name> \
  --pr=<pr number>

cocoa change-request request-approval

承認が要求されていない新しい状態のレコードについて承認を要求します。 実行中、記録は手動承認パスに従う。

オプション:

--crid="<ID>"
# or
--change-request-id="<ID>"
--provider         # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')

ServiceNow v1 または v2 プロバイダーを使用している場合に必要な環境変数:

SERVICENOW_TOKEN=    # ServiceNow API Token
SERVICENOW_URL=      # ServiceNow API URL

ServiceNow v3 プロバイダーを使用している場合の必須環境変数:

SERVICENOW_URL=       # ServiceNow API URL

追加の環境変数 ( ServiceNow v3 プロバイダーを使用している場合):

PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN=     # Access token obtained from the IAM service

GitHub Enterprise プロバイダーに必要な環境変数:

GHE_TOKEN=    # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG=   # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO=    # The repository name (optional, when --repo is not provided)

次のコマンドを実行します。

 cocoa change-request request-approval --crid="<insert-change-request-id-here>"

cocoa change-request task add

このコマンドは非推奨であり、 2.0.0で削除されます。 代わりに cocoa change-request attachment add を使用してください。

特定の変更要求に変更タスクを追加します。

オプション:

--description      # A more detailed description for the Change Task. [string]
--name             # Name of the Change Task. [string] [required]
--data             # Data for the Change Task or a path prefixed with @ to read the data from. [string] [default: "@/dev/stdin"]
--provider         # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')

ServiceNow v1 または v2 プロバイダーを使用している場合に必要な環境変数:

SERVICENOW_TOKEN=    # ServiceNow API Token
SERVICENOW_URL=      # ServiceNow API URL

ServiceNow v3 プロバイダーを使用している場合の必須環境変数:

SERVICENOW_URL=       # ServiceNow API URL

追加の環境変数 ( ServiceNow v3 プロバイダーを使用している場合):

PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN=     # Access token obtained from the IAM service

GitHub Enterprise プロバイダーに必要な環境変数:

GHE_TOKEN=    # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG=   # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO=    # The repository name (optional, when --repo is not provided)

次のコマンドを実行します。

$ cocoa change-request task add "CHGXXXXXXX" \
        --name='<task-name>' \
        --data='<data-for-the-task>'

$ cat data.txt | cocoa change-request task add "CHGXXXXXXX" --name='<task-name>'

$ cocoa change-request task add "CHGXXXXXXX" \
        --name='<task-name>' \
        --data='@<path/to/file>'

cocoa change-request task get

このコマンドは非推奨であり、 2.0.0で削除されます。 代わりに cocoa change-request attachment get を使用してください。

変更要求の特定の変更タスクを取得します。

オプション:

--provider         # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')

ServiceNow v1 または v2 プロバイダーを使用している場合に必要な環境変数:

SERVICENOW_TOKEN=    # ServiceNow API Token
SERVICENOW_URL=      # ServiceNow API URL

ServiceNow v3 プロバイダーを使用している場合の必須環境変数:

SERVICENOW_URL=       # ServiceNow API URL

追加の環境変数 ( ServiceNow v3 プロバイダーを使用している場合):

PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN=     # Access token obtained from the IAM service

GitHub Enterprise プロバイダーに必要な環境変数:

GHE_TOKEN=    # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG=   # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO=    # The repository name (optional, when --repo is not provided)

次のコマンドを実行します。

 cocoa change-request task get "CHGXXXXXXX" "CTASKXXXXXXX"

cocoa change-request task list

このコマンドは非推奨であり、 2.0.0で削除されます。 代わりに cocoa change-request attachment list を使用してください。

変更要求の変更タスクを一覧表示します。

オプション:

--provider         # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')

ServiceNow v1 または v2 プロバイダーを使用している場合に必要な環境変数:

SERVICENOW_TOKEN=    # ServiceNow API Token
SERVICENOW_URL=      # ServiceNow API URL

ServiceNow v3 プロバイダーを使用している場合の必須環境変数:

SERVICENOW_URL=       # ServiceNow API URL

追加の環境変数 ( ServiceNow v3 プロバイダーを使用している場合):

PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN=     # Access token obtained from the IAM service

GitHub Enterprise プロバイダーに必要な環境変数:

GHE_TOKEN=    # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG=   # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO=    # The repository name (optional, when --repo is not provided)

次のコマンドを実行します。

 cocoa change-request task list "<insert-change-request-id-here>"

cocoa change-request task update

このコマンドは非推奨であり、 2.0.0で削除されます。 代わりに cocoa change-request attachment update を使用してください。

特定の変更要求の変更タスクを更新します。

オプション:

--change-request-id  # The change request the change task belongs to [string] [required]
--change-task-id     # The change task id to be updated [string] [required]
--description        # A more detailed description for the Change Task. [string]
--data               # Data for the Change Task or a path prefixed with @ to read the data from. [string]
--provider           # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')

ServiceNow v1 または v2 プロバイダーを使用している場合に必要な環境変数:

SERVICENOW_TOKEN=    # ServiceNow API Token
SERVICENOW_URL=      # ServiceNow API URL

ServiceNow v3 プロバイダーを使用している場合の必須環境変数:

SERVICENOW_URL=       # ServiceNow API URL

追加の環境変数 ( ServiceNow v3 プロバイダーを使用している場合):

PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN=     # Access token obtained from the IAM service

GitHub Enterprise プロバイダーに必要な環境変数:

GHE_TOKEN=    # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG=   # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO=    # The repository name (optional, when --repo is not provided)

次のコマンドを実行します。

$ cocoa change-request task update
        --change-request-id='CHGXXXXXXX' \
        --change-task-id='CTASKXXXXXXX' \
        --data='<data-for-the-task>' \
        --description='<description>'

$ cat data.txt | cocoa change-request task update --change-request-id='CHGXXXXXXX' --change-task-id='CTASKXXXXXXX' --data='@/dev/stdin'

$ cocoa change-request task update --change-request-id='CHGXXXXXXX' --change-task-id='CTASKXXXXXXX' --data='@<path/to/file>'

ココア変更要求添付ファイル追加

特定の変更要求に変更添付ファイルを追加します。

オプション:

--description      # A more detailed description for the Change Task. [string]
--name             # Name of the Change Task. [string] [required]
--data             # Data for the Change Task or a path prefixed with @ to read the data from. [string] [default: "@/dev/stdin"]
--provider         # (Optional) Change Management service provider (choices: 'servicenow', 'github-enterprise', 'servicenow-v3', default: 'servicenow')

ServiceNow v1 または v2 プロバイダーを使用している場合に必要な環境変数:

SERVICENOW_TOKEN=    # ServiceNow API Token
SERVICENOW_URL=      # ServiceNow API URL

ServiceNow v3 プロバイダーを使用している場合の必須環境変数:

SERVICENOW_URL=       # ServiceNow API URL

追加の環境変数 ( ServiceNow v3 プロバイダーを使用している場合):

PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN=     # Access token obtained from the IAM service

GitHub Enterprise プロバイダーに必要な環境変数:

GHE_TOKEN=    # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG=   # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO=    # The repository name (optional, when --repo is not provided)

次のコマンドを実行します。

$ cocoa change-request attachment add "CHGXXXXXXX" \
        --name='<attachment-name>' \
        --data='<data-for-the-attachment>'

$ cat data.txt | cocoa change-request attachment add "CHGXXXXXXX" --name='<attachment-name>'

$ cocoa change-request attachment add "CHGXXXXXXX" \
        --name='<attachment-name>' \
        --data='@<path/to/file>'

cocoa change-要求添付 get

変更要求の特定の変更添付ファイルを取得します。

オプション:

--provider         # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')

ServiceNow v1 または v2 プロバイダーを使用している場合に必要な環境変数:

SERVICENOW_TOKEN=    # ServiceNow API Token
SERVICENOW_URL=      # ServiceNow API URL

ServiceNow v3 プロバイダーを使用している場合の必須環境変数:

SERVICENOW_URL=       # ServiceNow API URL

追加の環境変数 ( ServiceNow v3 プロバイダーを使用している場合):

PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN=     # Access token obtained from the IAM service

GitHub Enterprise プロバイダーに必要な環境変数:

GHE_TOKEN=    # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG=   # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO=    # The repository name (optional, when --repo is not provided)

次のコマンドを実行します。

 cocoa change-request attachment get "CHGXXXXXXX" "CTASKXXXXXXX"

ココア変更要求接続リスト

変更要求の変更添付ファイルを一覧表示します。

オプション:

--provider         # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')

ServiceNow v1 または v2 プロバイダーを使用している場合に必要な環境変数:

SERVICENOW_TOKEN=    # ServiceNow API Token
SERVICENOW_URL=      # ServiceNow API URL

ServiceNow v3 プロバイダーを使用している場合の必須環境変数:

SERVICENOW_URL=       # ServiceNow API URL

追加の環境変数 ( ServiceNow v3 プロバイダーを使用している場合):

PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN=     # Access token obtained from the IAM service

GitHub Enterprise プロバイダーに必要な環境変数:

GHE_TOKEN=    # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG=   # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO=    # The repository name (optional, when --repo is not provided)

次のコマンドを実行します。

 cocoa change-request attachment list "<insert-change-request-id-here>"

ココア変更要求添付ファイルの更新

特定の変更要求の変更添付ファイルを更新します。

オプション:

--change-request-id  # The change request the change task belongs to [string] [required]
--change-task-id     # The change task id to be updated [string] [required]
--description        # A more detailed description for the Change Task. [string]
--data               # Data for the Change Task or a path prefixed with @ to read the data from. [string]
--provider           # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')

ServiceNow v1 または v2 プロバイダーを使用している場合に必要な環境変数:

SERVICENOW_TOKEN=    # ServiceNow API Token
SERVICENOW_URL=      # ServiceNow API URL

ServiceNow v3 プロバイダーを使用している場合の必須環境変数:

SERVICENOW_URL=       # ServiceNow API URL

追加の環境変数 ( ServiceNow v3 プロバイダーを使用している場合):

PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN=     # Access token obtained from the IAM service

GitHub Enterprise プロバイダーに必要な環境変数:

GHE_TOKEN=    # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG=   # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO=    # The repository name (optional, when --repo is not provided)

次のコマンドを実行します。

$ cocoa change-request attachment update
        --change-request-id='CHGXXXXXXX' \
        --change-attachment-id='CTASKXXXXXXX' \
        --data='<data-for-the-attachment>' \
        --description='<description>'

$ cat data.txt | cocoa change-request attachment update --change-request-id='CHGXXXXXXX' --change-attachment-id='CTASKXXXXXXX' --data='@/dev/stdin'

$ cocoa change-request attachment update --change-request-id='CHGXXXXXXX' --change-attachment-id='CTASKXXXXXXX' --data='@<path/to/file>'

ココア証拠コマンド

cocoa evidence create

指定されたオプションから証拠を作成し、それをファイルに保存するか、コンソールにプリントする。

次のコマンドを実行します。

$ cocoa evidence create \
  --namespace=[choices: "ci", "cd"] \               # Pipeline type the evidence was collected from
  --evidence-name=<evidence-name> \                 # It will be used to name evidence-file in git
  --evidence-type=<evidence-type> \                 # e.g: com.ibm.unit_test
  --evidence-type-version=<evidence-type-version> \
  --result=[choices: "failure", "success"] \        # The result of the scan/test
  --issue=<issue-url> \                             # e.g: --issue=foo --issue=bar || --issue=foo
  --artifact=<artifact_url> <artifact_hash>\        # Url and hash pair(s) to the test artifact(s)
  --log=<log_url> <log_hash> \                      # Url and hash pair(s) to the log(s)
  --pipeline-id=<pipeline-id> \
  --pipeline-run-id=<pipeline-run-id> \
  --pipeline-run-url=<pipeline-run-url> \
  --toolchain-crn=<toolchain-crn> \                 # Name of the toolchain cloud resource
  --output=<filename>                                # If present, the evidence will be saved to the given file.

CLI のオプションは、issue, log, artifact 以外は環境変数からも設定できます。 複数の問題または成果物には、複数の問題フラグまたは成果物フラグを指定する必要があります。 以下に例を示します。

 cocoa evidence create --artifact <url> <hash>  --artifact <url> <hash> --issue <issue-url> --issue <issue-url>

artifact は、アーティファクト・ファイルを指すURLとハッシュで構成され、前の例と同じように指定しなければなりません。

cocoa evidence format-summary

エビデンス・サマリーを人間が読み取り可能な形式にします。 このサマリーは、変更要求の内容に入れることができます。

次のコマンドを実行します。

$ cocoa evidence format-summary \
  --input=<filepath> \          # (default: -, referring to stdin) If present, the formatted evidence will be read from the given file.
  --output=<filepath>           # (default: -, referring to stdout) If present, the formatted evidence will be saved to the given file.
# Reading from stdin and printing to stdout:
$ cat raw-summary.json | cocoa evidence format-summary -i - -o - | tee formatted-summary.txt
$ cat raw-summary.json | cocoa evidence format-summary | tee formatted-summary.txt
# Reading to and from file:
$ cocoa evidence format-summary --input=raw-summary.json --output=formatted-summary.txt

ココア証拠マークダウン-要約

エビデンス要約を、 GitHub プル要求コメントとしてフィードできるマークダウン形式にフォーマット設定します。

入力は未加工の要約で、以下の 2 つの形式のいずれかにすることができます。

  • JSON 形式の要約 ( cocoa evidence summarize コマンドの出力)。
  • 集約された要約。これは、個々のアプリ要約の JSON 配列です。

集約された要約が入力として渡されると、出力により、要約内のアプリケーションに基づいてエビデンス状況がグループ化されます。

オプション・フラグ:

  • --detailed: フラグが true に設定されている場合、詳細なマークダウン・サマリーが生成されます (デフォルトでは、トリム・ダウン・サマリーの場合は truefalse に設定されます)。

次のコマンドを実行します。

$ cocoa evidence markdown-summary \
  --input=<filepath> \          # (default: -, referring to stdin) If present, the formatted evidence will be read from the given file.
  --output=<filepath>           # (default: -, referring to stdout) If present, the formatted evidence will be saved to the given file.
# Reading from stdin and printing to stdout:
$ cat raw-summary.json | cocoa evidence markdown-summary -i - -o - | tee markdown-summary.md
$ cat aggr-summary.json | cocoa evidence markdown-summary | tee markdown-summary.md
# Reading to and from file:
$ cocoa evidence markdown-summary --input=raw-summary.json --output=markdown-summary.md

cocoa evidence upload

指定されたバックエンドに証拠をアップロードします。 バックエンドは、異なるエビデンス・ロッカー・タイプにすることができます (例えば、Object Storage、GitHub、DevOps Insights など)。 異なるロッカーには、別のパラメーターを指定する必要があります。

DevOps Insights は、まだサポートされていません。

必要なオプション:

--backend

必要な環境変数:

EVIDENCE_REPO_ORG=  # Evidence repo org (Required if you are using 'git' backend)
EVIDENCE_REPO_NAME= # Evidence repo name (Required if you are using 'git' backend)

必要な環境変数(使用している場合)GitHub:

GHE_TOKEN=          # Github Enterprise API Token (Optional if you are using --git-token-path)

Cloud Object Storageを使用している場合は、必須の環境変数:

COS_API_KEY=        # Cloud Object Storage API Key (Required if you are using 'cos' backend)
COS_BUCKET_NAME=    # Bucket Name where the evidence will be uploaded in the COS Instance (Required if you are using 'cos' backend)
COS_ENDPOINT=       # The COS API Endpoint matching the region where the bucket is located (Required if you are using 'cos' backend)

github を使用している場合は、 --git-token-path フィールドを使用して GitHub トークンを設定し、 --git-api-url フィールドを使用して、 GHE_TOKEN 環境変数および GH_URL 環境変数の代わりに # GitHub Enterprise API URL を設定します。 両方が指定されている場合は、 --git-token-path--git-api-url が優先されます。

次のコマンドを実行します。

$ cocoa evidence upload

$ cocoa evidence upload \
  --backend=[choices: "git", "insights", "cos"] \   # e.g. --backend=cos,git,insights
  --namespace=[choices: "ci", "cd"] \               # Pipeline type the evidence was collected from
  --evidence-name=<evidence-name> \                 # It will be used to name evidence-file in git
  --evidence-type=<evidence-type> \                 # e.g: com.ibm.unit_test
  --evidence-type-version=<evidence-type-version> \
  --result=[choices: "failure", "success"] \        # The result of the scan/test
  --issue=<issue-url> \                             # e.g: --issue=foo --issue=bar || --issue=foo
  --artifact=<artifact_url> <artifact_hash>\        # Url and hash pair(s) to the test artifact(s)
  --log=<log_url> <log_hash> \                      # Url and hash pair(s) to the log(s)
  --pipeline-id=<pipeline-id> \
  --pipeline-run-id=<pipeline-run-id> \
  --pipeline-run-url=<pipeline-run-url> \
  --toolchain-crn=<toolchain-crn>                   # Name of the toolchain cloud resource

CLI のオプションは、backend, issue, log, artifact 以外は環境変数からも設定できます。 複数の問題または成果物には、複数の問題フラグまたは成果物フラグを指定する必要があります。 以下に例を示します。

 cocoa evidence upload --backend=git --artifact <url> <hash>  --artifact <url> <hash> --issue <issue-url> --issue <issue-url> --git-provider='github'

artifact は、成果物ファイルを指す URL とハッシュで構成され、前の例と同じ方法でこれらの項目を提供します。

cocoa evidence summarize

証拠品ロッカーから証拠品を照会し、その内容から証拠品要約を作成する。 バックエンドは、Object StorageやGitHubのように、異なるエビデンスロッカータイプにすることができます。 現在、バックエンドとして gitcos がサポートされています。 異なるロッカーには、別のパラメーターを指定する必要があります。

Git の場合に必要な環境変数:

EVIDENCE_REPO_ORG=  # Use this environment varibale to provide the owner organisation of the evidence repository (Required if you are using 'git' backend)
EVIDENCE_REPO_NAME= # Use this environment varibale to provide the name of the evidence repository (Required if you are using 'git' backend)
PIPELINE_RUN_ID=    # Can be used instead of '--pipeline-run-id' option
TOOLCHAIN_CRN=      # Can be used instead of '--toolchain-crn' option

必要な環境変数(使用している場合)GitHub:

GHE_TOKEN=          # Github Enterprise API Token (Optional if you are using --git-token-path)

Git のオプション:

--backend           # (Required) Specifies the type of locker from where the evidences are queried
--repo              # Evidence Repositories name (can be substituted by EVIDENCE_REPO_NAME environment variable)
--org               # Evidence Repositories owner organisation (can be substituted by EVIDENCE_REPO_ORG environment variable)
--pipeline-run-id   # (Required)
--toolchain-crn     # (Required)
--prefix-list       # (Required) a list of paths separated by comma where evidences can be found in the repository
--output            # (Optional) file name to write the evidence summary into
--git-token-path    # (Optional) Github Token's path
--git-api-url       # (Optional) Github API url

github を使用している場合は、 --git-token-path フィールドを使用して GitHub トークンを設定し、 --git-api-url フィールドを使用して、 GHE_TOKEN 環境変数および GH_URL 環境変数の代わりに # GitHub Enterprise API URL を設定します。 GHE_TOKEN GH_URL--git-token-path --git-api-url の両方のペアが指定されている場合は、 --git-token-path--git-api-url が優先されます。

デフォルトでは、呼び出しごとに CLI を使用することにより、 Git ロッカーの最新バージョンで作業することが保証されます。 この動作を無効にするには、 COCOA_USE_CACHE0falseno、または n 以外の任意の値に設定します。 この場合、CLI はその内部キャッシュを使用してエビデンスを (はるかに高速で) 検索しますが、結果が失効する可能性があります。

Cloud Object Storageを使用している場合は、必須の環境変数:

COS_API_KEY=      # COS api token
COS_BUCKET_NAME=  # COS bucket name where evidences are stored
COS_ENDPOINT=     # COS endpoint where the bucket is available
PIPELINE_RUN_ID=  # Can be used instead of '--pipeline-run-id' option
TOOLCHAIN_CRN=    # Can be used instead of '--toolchain-crn' option

COS のオプション:

--backend         # (Required) Specifies the type of locker from where the evidences are queried
--pipeline-run-id # (Required)
--toolchain-crn   # (Required)
--prefix-list     # (Required) a list of paths separated by comma where evidences can be found in the repository
--output          # (Optional) file name to write the evidence summary into

次のコマンドを実行します。

# Save the evidence summary to 'summary.json' file.
$ cocoa evidence summarize \
  --backend='git' \
  --pipeline-run-id='id-123-123' \
  --toolchain-crn='crn-123-123' \
  --prefix-list='raw/ci/pipeline-run-id-1,raw/ci/pipeline-run-id-2' \
  --output='summary.json'

# Print the evidence summary to the console
$ cocoa evidence summarize \
  --backend='git' \
  --pipeline-run-id='id-123-123' \
  --toolchain-crn='crn-123-123' \
  --prefix-list='raw/ci/pipeline-run-id-1,raw/ci/pipeline-run-id-2'

cocoa artifact コマンド

cocoa artifact upload

指定されたバックエンドに成果物をアップロードします。 バックエンドは、異なるエビデンス・ロッカー・タイプにすることができます (例えば、Object Storage、GitHub、DevOps Insights など)。 異なるロッカーには、別のパラメーターを指定する必要があります。

オプション:

--backend           # (Required) Specifies the types of lockers we upload the artifact ('cos', 'git')
--pipeline-run-id   # The ID of the PipelineRun running the CLI command
--namespace         # Specifies the pipeline the evidence is collected from
--upload-path       # If present, this overrides the artifact name with the specified value
--is-summary        # If present, this uploads the artifact to the location where evidence summary is usually stored

Git のオプション:

--git-token-path    #(Optional) Github Token's path
--git-api-url           #(Optional) Github API url

必要な環境変数:

PIPELINE_RUN_ID=    # Can be used instead of '--pipeline-run-id' option
NAMESPACE=          # Can be used instead of '--namespace' option

必須の環境変数 (「git」プロバイダーを使用している場合):

EVIDENCE_REPO_ORG=  # The Git repo org (Required if you are using 'git' backend)
EVIDENCE_REPO_NAME= # The Git repo name (Required if you are using 'git' backend)

必要な環境変数(使用している場合)GitHub:

GHE_TOKEN=          # Github Enterprise API Token (Optional if you are using --git-token-path)

Cloud Object Storageを使用している場合は、必須の環境変数:

COS_API_KEY=        # Cloud Object Storage API Key (Required if you are using 'cos' backend)
COS_BUCKET_NAME=    # Bucket Name where the artifact will be uploaded in the COS Instance (Required if you are using 'cos' backend)
COS_ENDPOINT=       # The COS API Endpoint matching the region where the bucket is located (Required if you are using 'cos' backend)

github を使用している場合は、 --git-token-path フィールドを使用して GitHub トークンを設定し、 --git-api-url フィールドを使用して、 GHE_TOKEN 環境変数および GH_URL 環境変数の代わりに # GitHub Enterprise API URL を設定します。 GHE_TOKEN GH_URL--git-token-path --git-api-url の両方のペアが指定されている場合は、 --git-token-path--git-api-url が優先されます。

次のコマンドを実行します。

$ cocoa artifact upload

$ cocoa artifact upload \
  --backend=[choices: "git", "cos"] \ # e.g. --backend=cos,git
  --pipeline-run-id=<pipeline-run-id> # can be substituted by PIPELINE_RUN_ID
  --namespace=[choices: "ci", "cd"] \ # Pipeline type the evidence was collected from, can be substituted by NAMESPACE
  --is-summary        # If present, this uploads the artifact to the location where evidence summary is usually stored
  <file-path>

CLI のオプションは、backendupload-path 以外は環境変数からも設定できます。

cocoa set-status

コミットの状況を設定します。 現在の実装は、GitHub でテストされています。 GitHub の状況に関する資料を参照してください。

必要な環境変数:

GHE_ORG=      # Github organization/username
GHE_REPO=     # Github repository
GHE_COMMIT=   # Github commit hash

必要な環境変数(使用している場合)GitHub:

GHE_TOKEN=    # Github token (Optional if you are using --git-token-path)

github を使用している場合は、 --git-token-path フィールドを使用して GitHub トークンを設定し、 --git-api-url フィールドを使用して、 GHE_TOKEN 環境変数および GH_URL 環境変数の代わりに # GitHub Enterprise API URL を設定します。 GHE_TOKEN GH_URL--git-token-path --git-api-url の両方のペアが指定されている場合は、 --git-token-path--git-api-url が優先されます。

Git のオプション:

--git-token-path    #(Optional) GitHub token's path
--git-api-url       #(Optional) GitHub API url

次のコマンドを実行します。

$ cocoa set-status \
 --state="pending" \
 --targetURL="https://cloud.ibm.com/devops/pipelines/tekton/some-toolchain/runs/some-pipelinerun/lint/lint?env_id=ibm:yp:us-south" \
 --context="tekton/lint" \
 --description="Tekton linter is running."

ココア・インベントリー・コマンド

cocoa inventory add

インベントリ・リポジトリに値を追加します。 name オプションを持つファイルが存在しなければ、それを上書きします。

必要な環境変数:

GHE_ORG=     # Github Organization (required if --org option is not specified).
GHE_REPO=    # Github Repository (required if --repo option is not specified).

必要な環境変数(使用している場合)GitHub:

GHE_TOKEN=    # Github Enterprise API Token(Optional if you are using --git-token-path)

Git のオプション:

--git-token-path    #(Optional) Github Token's path
--git-api-url           #(Optional) Github API url
表 1. Gitのオプション
オプション 説明 値のタイプ 必須またはデフォルト値
成果物 (artifact) 成果物の名前。 ストリング 必須
バージョン アプリケーションのバージョン。 ストリング 必須
リポジトリー URL アプリケーションのリポジトリ。 ストリング 必須
PIPELINE-RUN-ID パイプラインの実行の ID。 ストリング 必須
コミット社 成果物のビルド元のアプリケーション・リポジトリーのコミット ストリング 必須
名前 成果物が属しているアプリケーションの名前 ストリング 必須
ビルド番号 ビルド番号。 number 必須
組織 (org) インベントリー・リポジトリーを所有する GitHub 組織。 ストリング
repo インベントリ・リポジトリの名前。 ストリング
app-成果物 JSON 形式の任意のアプリケーション・コンテンツ ストリング
タイプ 成果物のタイプ ストリング 必須
sha256 成果物の sha256 ハッシュ ストリング 必須
プロビナンス 成果物を指す URL (例えば、ビルドされたイメージ) ストリング 必須
シグニチャー 成果物の署名 ストリング 必須
環境 項目が追加される環境の名前です。 ストリング "マスター"
Git-Provider * Git バージョン管理サービス・プロバイダー。 ストリング * 「github」
git-token-path シークレットの読み取り元の Git トークン・パス ストリング
git-api-url Git API URL ストリング

次のコマンドを実行します。

$ cocoa inventory add \
  --artifact=cocoa-script-cli \
  --type=type \
  --sha256=786800e8e48938664fe2397ca14ab8dabd48f34656ef5cfda4143b4519cb714f \
  --signature=123123valid \
  --name=cocoa-cli \
  --repository-url=http://validURL.com \
  --commit-sha=8e86dc4647ce28632103dce46b756c70d339349a \
  --version=v4 \
  --build-number=33 \
  --pipeline-run-id=123123valid \
  --git-token-path=./git-token \
  --org=test \
  --app-artifacts='{"app": "test", "some_value": "value"}' \
  --repo=repository
$ cocoa inventory add \
  --environment=environment \
  --artifact=foo-helm-chart/foo/chart.yaml \
  --repository-url=http://validURL.com \
  --commit-sha=786800e8e48938664fe2397ca14ab8dabd48f34656ef5cfda4143b4519cb714f \
  --build-number=33 \
  --pipeline-run-id=123123valid \
  --version=v4 \
  --name=chart

cocoa inventory get

インベントリー・リポジトリーからエントリーを取得します。 ターゲットは、特定のバージョンまたは環境にすることができます。 --version または --environment のどちらかを 1 つだけ使用してください。 --property オプションを指定しない場合は、インベントリーのエントリーの内容がすべて出力されます。

必要な環境変数(使用している場合)GitHub:

GHE_TOKEN=    # Github Enterprise API Token (Optional if you are using --git-token-path)

Git のオプション:

--git-token-path       #(Optional) Github Token's path
--git-api-url          #(Optional) Github API url

github を使用している場合は、 --git-token-path フィールドを使用して GitHub トークンを設定し、 --git-api-url フィールドを使用して、 GHE_TOKEN 環境変数および GH_URL 環境変数の代わりに # GitHub Enterprise API URL を設定します。 GHE_TOKEN GH_URL--git-token-path --git-api-url の両方のペアが指定されている場合は、 --git-token-path--git-api-url が優先されます。

デフォルトでは、呼び出しごとに CLI を使用することにより、 Git ロッカーの最新バージョンで作業することが保証されます。 この動作を無効にするには、 COCOA_USE_CACHE0falseno、または n 以外の任意の値に設定します。 この場合、CLI はその内部キャッシュを使用してエビデンスを (はるかに高速で) 検索しますが、結果が失効する可能性があります。

次のコマンドを実行します。

# Uses the environment as target, and pretty-prints only a given property of the inventory entry to the console.
$ cocoa inventory get \
  --org='Github-ID' \
  --repo='compliance-inventory-repo' \
  --entry='hello-compliance-app' \
  --environment='master' \
  --property='name'

# Uses the version as target, and pretty-prints the whole content of the inventory entry to the console.
$ cocoa inventory get \
  --org='Github-ID' \
  --repo='compliance-inventory-repo' \
  --entry='hello-compliance-app' \
  --version='v1'

cocoa inventory get-sha

インベントリリポジトリからラベルや環境の最新のコミットハッシュを取得します。 --label または --environment のどちらかを 1 つだけ使用してください。

必要な環境変数(使用している場合)GitHub:

GHE_TOKEN=    # Github Enterprise API Token (Optional if you are using --git-token-path)

Git のオプション:

--git-token-path    #(Optional) Github Token's path
--git-api-url       #(Optional) Github API url

github を使用している場合は、 --git-token-path フィールドを使用して GitHub トークンを設定し、 --git-api-url フィールドを使用して、 GHE_TOKEN 環境変数および GH_URL 環境変数の代わりに # GitHub Enterprise API URL を設定します。 GHE_TOKEN GH_URL--git-token-path --git-api-url のペアが指定されている場合は、 --git-token-path--git-api-url が優先されます。

次のコマンドを実行します。

# Get the latest commit hash of the staging branch
$ cocoa inventory get-sha \
  --org='Github-ID' \
  --repo='compliance-inventory-repo' \
  --environment='staging'

# Get the commit hash of the "pipeline-run-id" label
$ cocoa inventory get-sha \
  --org='Github-ID' \
  --repo='compliance-inventory-repo' \
  --label='pipeline-run-id'

cocoa inventory label

インベントリーのエントリーにラベルを追加するか、またはインベントリーのラベルを移動します。 ターゲットは、特定のブランチの最新のコミットまたは別のラベルにすることができます。

オプション:

--org          # The Github organisation which owns the inventory repository.
--repo         # The name of the inventory repository.
--environment  # The inventory branch
--to-label     # Another label in the inventory, that will be looked up/removed

必要な環境変数:

GHE_ORG=     # Github Organization (required if --org option is not specified).
GHE_REPO=    # Github Repository (required if --repo option is not specified).

必要な環境変数(使用している場合)GitHub:

GHE_TOKEN=    # Github Enterprise API Token (Optional if you are using --git-token-path)

Git のオプション:

--git-token-path    #(Optional) Github Token's path
--git-api-url           #(Optional) Github API url

github を使用している場合は、 --git-token-path フィールドを使用して GitHub トークンを設定し、 --git-api-url フィールドを使用して、 GHE_TOKEN 環境変数および GH_URL 環境変数の代わりに # GitHub Enterprise API URL を設定します。 GHE_TOKEN GH_URL--git-token-path --git-api-url の両方のペアが指定されている場合は、 --git-token-path--git-api-url が優先されます。

次のコマンドを実行します。

# label the latest state on "staging" branch
$ cocoa inventory label add \
  --org='Github-ID' \
  --repo='compliance-inventory-repo' \
  --environment='staging' \
  "new-label-to-add"
# attach a label to another label (to the same commit)
$ cocoa inventory label add \
  --org='Github-ID' \
  --repo='compliance-inventory-repo' \
  --to-label="some-label" \
  "new-label-to-add"
# move or create the `staging_latest` label to another label (to the same commit)
$ cocoa inventory label move \
  --org='Github-ID' \
  --repo='compliance-inventory-repo' \
  --to-label="some-label" \
  "label-to-move"

cocoa inventory promote

ある環境から別の環境にインベントリーのエントリーをプロモートします。 ソース環境は、ブランチまたはタグのどちらかにすることができます。

必要な環境変数:

GHE_ORG=          # Github Organization (required if --org option is not specified).
GHE_REPO=         # Github Repository (required if --repo option is not specified).
PIPELINE_RUN_ID=  # Can be used instead of --pipeline-run-id (either the option or the variable is required).

必要な環境変数(使用している場合)GitHub:

GHE_TOKEN=    # Github Enterprise API Token (Optional if you are using --git-token-path)

Git のオプション:

--git-token-path    #(Optional) Github Token's path
--git-api-url           #(Optional) Github API url

github を使用している場合は、 --git-token-path フィールドを使用して GitHub トークンを設定し、 --git-api-url フィールドを使用して、 GHE_TOKEN 環境変数および GH_URL 環境変数の代わりに # GitHub Enterprise API URL を設定します。 両方とも指定されている場合は、 --git-token-path--git-api-url が優先されます。

次のコマンドを実行します。

$ cocoa inventory promote \
  --org='Github-ID' \
  --repo='compliance-inventory-repo' \
  --source='master' \
  --target='prod' \
  --priority='Critical' \
  --assigned-to='employee@ibm.com' \
  --description='desc' \
  --purpose='purpose' \
  --impact='impact' \
  --customer-impact='impact' \
  --deployment-impact='small' \
  --backout-plan='rollback'

ココア・インシデント・コマンド

cocoa incident add

commit-hash に基づいて、パイプラインの実行で失敗したタスクについてのインシデント Issue を作成または更新します。

オプション:

--task              # (Required) The name of the failing task
--commit-hash       # (Required) The commit hash which triggered the pipeline run
--pipeline-run-url  # The pipeline run url where the task ran
--org               # The incident issue repo org
--repo              # The incident issue repo name
--assignee          # (Optional) Assignee(s) for the incident issue (github username) e.g: --assigne=jane-doe --assignee=john-smith
--app-repo-url      # The app repo URL
--label             # Label(s) to add to the incident issue (optional) e.g: --label=foo --label=bar
--git-token-path    # (Optional) Github Token's path
--git-api-url       #(Optional) Github API url

必要な環境変数:

GHE_ORG=                    # Can be used instead of --org (either the option or the variable is required)
GHE_REPO=                   # Can be used instead of --repo (either the option or the variable is required)
PIPELINE_RUN_URL=           # Can be used instead of --pipeline-run-url (either the option or the variable is required)
APP_REPO_URL=               # Can be used instead of --app-repo-url (either the option or the variable is required)

必要な環境変数(使用している場合)GitHub:

GHE_TOKEN=    # Github Enterprise API Token (Optional if you are using --git-token-path)

github を使用している場合は、 --git-token-path フィールドを使用して GitHub トークンを設定し、 --git-api-url フィールドを使用して、 GHE_TOKEN 環境変数および GH_URL 環境変数の代わりに # GitHub Enterprise API URL を設定します。 両方が指定されている場合は、 --git-token-path--git-api-url が優先されます。

次のコマンドを実行します。

 cocoa incident add --task=<failing-task-name> --commit-hash=<abc123>

ココア・インシデント・プロセス

このコマンドは、提供されたスキャン結果を処理し、提供されたリポジトリー内に脆弱性ごとにインシデント問題を作成します ( cocoa incident add のように実行されるタスクごとではありません)。 サブジェクトとインシデントのペアの問題が既に存在する場合、新しい問題は作成されません。

--set-grace-period を設定すると、猶予期間が設定された問題が作成されるか、既存の問題が更新され、猶予期間が設定されます。

有効化されている場合、猶予期間は 15 日に設定されます。 インシデントの問題に「免除」または「猶予期間」が設定されている場合、チェックは問題をリストしますが、エラーのマークは付けません。

例外は CR VA で構成されるか、または例外承認のためにインシデントまたは CVE を送信することができます。 承認された場合は、インシデントの問題を編集し ( Excempt: **true** を設定)、承認された要求にリンクできます。

現在サポートされているスキャン結果ファイル:

  • Container Registry VA スキャン (オプション --type va)
  • CRA 脆弱性スキャン (オプション --type cra)
  • Xray (オプション --type xray)
  • OWASP ZAP (オプション --type owasp-zap)
  • OWASP ZAP UI (オプション --type owasp-zap-ui)
  • Twistlock (オプション --type twistlock)
  • ピア・レビュー・スキャン (オプション --type peer-review)
  • GoLang セキュリティー・スキャン (オプション --type gosec)
  • SonarQube Scan (オプション --type sonarqube)
  • Mend Scan (オプション --type mend)
  • Checkov (オプション --type checkov)
  • Terraform の CRA 脆弱性スキャン (オプション --type cra-tf)
  • Terraform セキュリティー・スキャン (オプション --type tfsec)
  • Fips Scanner (オプション --type fips-scanner)
  • コントラスト・サスト (オプション --type contrast-sast)
  • シークレットの検出 (オプション --type detect-secrets)
  • Sysdig (オプション --type sysdig)

Container Registry VA と結果の形式の詳細については、Vulnerability Advisor for IBM Cloud Container Registry を参照してください。 CRA 脆弱性スキャナーについて詳しくは、 コード・リスク・アナライザーの構成の資料を参照してください。

使用方法:

$ cocoa incident process \
  <options> \
  <path to result file>

オプション:

--type             # (Required) Scan type [cra | va]
--subject          # (Required) Subject of scans (repo, or image name)
--drilldown-url    # (Required) URL to the point where the incident was found (can be a pipeline run, a commit hash or an image URL with digest)
--set-grace-period # Should the created incidents have Grace period set
--git-provider     # Git service provider [github] Default is "github"
--org              # The incident issue repository org
--repo             # The incident issue repository name
--label            # Label(s) to add to the incident issue (optional) e.g: --label=foo --label=bar
--assignee         #(Optional) Assignee(s) for the incident issue (github username) e.g: --assignee=jane-doe --assignee=john-smith
--git-token-path   #(Optional) Github Token's path
--git-api-url      #(Optional) Github API url
--custom-exempt-label # (Optional) Defines the custom label with which the incident issue has been marked as exempted
--custom-comment   # (Optional) Additional text to be added to issue comments
--format           # (Optional) Format of the output ("list", "json", default: "list")

必要な環境変数:

INCIDENT_REPO_ORG=        # Can be used instead of --org (either the option or the variable is required)
INCIDENT_REPO_NAME=       # Can be used instead of --repo (either the option or the variable is required)

必要な環境変数(使用している場合)GitHub:

GHE_TOKEN=                # Github Enterprise API Token (Optional if you are using --git-token-path)

github を使用している場合は、 --git-token-path フィールドを使用して GitHub トークンを設定し、 --git-api-url フィールドを使用して、 GHE_TOKEN 環境変数および GH_URL 環境変数の代わりに # GitHub Enterprise API URL を設定します。 両方が指定されている場合は、 --git-token-path--git-api-url が優先されます。

戻り値:

  • 問題が見つからない場合、または検出されたすべての問題に免除期間または猶予期間が設定されている場合、コマンドはゼロ状況で終了します。
  • 検出された問題のいずれかに免除または猶予期間が設定されていない場合、コマンドはゼロ以外の状況で終了します。
  • If format == list-コマンドは、結果ファイルとサブジェクトに従って検出または作成されたインシデント問題 URL をリストします。
  • If format == json-このコマンドは、結果ファイルとサブジェクトに従って検出、作成、および自動クローズされた各問題の検出結果オブジェクトの配列 (追加の問題情報) を含む JSON を出力します。
  • 問題に対応する検出結果 JSON オブジェクトの構造:
{
 "id": string,
 "due_date": string,
 "severity": ("high", "medium", "low", "critical, "informational"),
 "first_found": "string" (optional),
 "url": string,
 "found_status": ("new", "existing", "autoclosed", "readonly"),
 "has_exempt": boolean
}

次のコマンドを実行します。

$ cocoa incident process \
  --type va \
  --subject us.icr.io/service-image \
  --drilldown-url us.icr.io/service-image@sha256:digest \
  path/to/scan-result.json

ココア・インシデント・プロセス-レガシー

このコマンドは、スキャン・ファイルが使用できない場合に、シナリオ用に提供されたリポジトリーにインシデントの問題を作成します。 通常、このようなシナリオは、単体テストの失敗、ブランチ保護の失敗、受け入れテストの失敗、イメージ署名の失敗など、脆弱性に関連しない障害になります。 これらの失敗は脆弱性ではありませんが、コンプライアンス体制からの逸脱になります。 インシデント・サブジェクト・ツールの組み合わせに問題が既に存在する場合、コマンドは新しい問題を作成しません。 デフォルトでは、 high 重大度レーティングは、作成された問題に設定されています。

--set-due-date が設定されている場合、このコマンドは問題を作成するか、既存の問題を期限付きで更新します。 期限は、重大度に基づいて、問題の猶予期間から計算されます。

--close-resolved-issues フラグが設定されている場合、コマンドは、現在の実行と同じツール、サブジェクト、およびインシデント ID を使用して、未解決の問題を検索します。 --current-statussuccess として渡されているときに問題が検出された場合、コマンドはそれらの問題をクローズします。

--read-only が設定されている場合、このコマンドは新しい問題を作成したり、既存の問題を修正したりすることはありません。 結果が処理され、結果について既存の問題が収集されます。 読み取り専用モードがアクティブ化されていない場合、出力には、問題で追跡されるはずの問題 URL リストが含まれます。

使用方法:

cocoa incident process-legacy \
  <options>

オプション:

--type             # (Required) Tool type
--subject          # (Required) Subject of scans (repo, or image name)
--drilldown-url    # (Required) URL to the point where the incident was found (can be a pipeline run, a commit hash or an image URL with digest)
--set-grace-period # Should the created incidents have Grace period set
--git-provider     # Git service provider [github] Default is "github"
--org              # The incident issue repository org
--repo             # The incident issue repository name
--label            # Label(s) to add to the incident issue (optional) e.g: --label=foo --label=bar
--assignee          #(Optional) Assignee(s) for the incident issue (github username) e.g: --assignee=jane-doe --assignee=john-smith
--git-token-path    #(Optional) Github Token's path
--git-api-url           #(Optional) Github API url
--close-resolved-issues # (Optional) Checking and closing resolved issues
--pipeline-run-url      # (Optional) The url to the pipeline run running the CLI command
--is-prod          # (Optional) Flag for whether or not the command was run in production environment. Default is false.
--read-only        # (Optional) Process result file in read-only mode (return found and existing issues, do not create new ones, set processed status to failure or success). Default is false
--custom-exempt-label # (Optional) Defines the custom label with which the incident has been marked as exempted
--incident-id         # (Required) Defines the incident ID to be used for creating legacy incident
--current-status      # (Required) Current status to be treated as success or failure [choices: "success", "failure"]
--custom-comment   # (Optional) Additional text to be added to issue comments
--format           # (Optional) Format of the output ("list", "json", default: "list")
--additional-comment  # (Optional) Additional comment for the issue on every run

環境変数:

INCIDENT_REPO_ORG=    # Can be used instead of --org (either the option or the variable is required)
INCIDENT_REPO_NAME=   # Can be used instead of --repo (either the option or the variable is required)
# Required Environment Variables, if using GitHub:

GHE_TOKEN=    # Github Enterprise API Token (Optional if using --git-token-path)

github を使用している場合は、 --git-token-path フィールドを使用して GitHub トークンを設定し、 --git-api-url フィールドを使用して GHE_TOKEN 環境変数および GH_URL 環境変数の代わりに GitHub Enterprise API URL (デフォルトは https://github.ibm.com/api/v3) を設定できます。 GHE_TOKEN GH_URL--git-token-path --git-api-url の両方のペアが提供されている場合は、 --git-token-path--git-api-url が優先されます。

戻り値:

  • このコマンドは、 --current-statusfailure として渡された場合に検出または作成されたインシデント問題の URL をリストします。 また、このコマンドは、 --current-statusfailure として渡された場合に、同じインシデント・ツールとサブジェクトの組み合わせに一致するインシデントの問題の URL を閉じます。
  • --read-only モードでは、検出されたインシデントに問題が見つからない場合、そのインシデントの詳細がコマンドによってリストされます。
  • 問題が見つからない場合、または見つかったすべての問題に免除ラベルが設定されている場合、コマンドはゼロ状況で終了します。
  • 検出された問題のいずれかに免除ラベルが設定されていない場合、コマンドはゼロ以外の状況で終了します。
  • --read-only モードでは、問題のない新規インシデントが検出された場合、コマンドはゼロ以外の状況で終了します。
  • If format == list-コマンドは、 --current-statusfailure として渡された場合に検出または作成されたインシデント問題の URL をリストします。
  • If format == json-このコマンドは、結果ファイルとサブジェクトに従って検出、作成、および自動クローズされた各問題の検出結果オブジェクトの配列 (追加の問題情報) を含む JSON を出力します。
  • 問題に対応する検出結果 JSON オブジェクトの構造:
{
 "id": string,
 "due_date": string,
 "severity": ("high", "medium", "low", "critical, "informational"),
 "first_found": "string" (optional),
 "url": string,
 "found_status": ("new", "existing", "autoclosed", "readonly"),
 "has_exempt": boolean
}

次のコマンドを実行します。

$ cocoa incident process-legacy \
   --type jest \
   --subject us.icr.io/service-image \
   --drilldown-url us.icr.io/service-image@sha256:digest \
   --incident-id com.ibm.unit_tests_master \
   --current-status success \
   --close-resolved-issues

ココア・インシデント評価

due_date および免除ラベルに基づいて問題の状況を評価し、問題の検出結果を出力します。

使用方法:

$ cocoa incident evaluate \
  <options> \
  <filePath>

オプション:

--git-provider         # Git service provider [github] Default is "github"
--org                  # The incident issue repository org
--repo                 # The incident issue repository name
--filePath             # Path to the JSON file that contains issues to be evaluated
--git-token-path       # (Optional) Github Token's path
--git-api-url          # (Optional) Github API url
--custom-exempt-label  # (Optional) Defines the custom label with which the incident issue has been marked as exempted
--is-prod              # (Optional) Whether or not the command was run in prod environment
--format               # (Optional) Format of the output ("list", "json", default: "list")

必要な環境変数:

INCIDENT_REPO_ORG=        # Can be used instead of --org (either the option or the variable is required)
INCIDENT_REPO_NAME=       # Can be used instead of --repo (either the option or the variable is required)

必要な環境変数(使用している場合)GitHub:

GHE_TOKEN=                # Github Enterprise API Token (Optional if you are using --git-token-path)

github を使用している場合は、 --git-token-path フィールドを使用して GitHub トークンを設定し、 --git-api-url フィールドを使用して、 GHE_TOKEN 環境変数および GH_URL 環境変数の代わりに # GitHub Enterprise API URL を設定します。 両方が指定されている場合は、 --git-token-path--git-api-url が優先されます。

戻り値:

  • 検出されたすべての問題に「免除」または「猶予」のいずれかの期間が設定されている場合、コマンドはゼロの状況で終了します。
  • 検出された問題のいずれかに免除または猶予期間が設定されていない場合、コマンドはゼロ以外の状況で終了します。
  • 検出結果の JSON 配列。
  • 問題に対応する検出結果 JSON オブジェクトの構造。
json
{
  "id": string,
  "due_date": string,
  "severity": ("high", "medium", "low", "critical, "informational"),
  "first_found": "string" (optional),
  "url": string,
  "found_status": ("new", "existing", "autoclosed", "readonly"),
  "has_exempt": boolean
}

次のコマンドを実行します。

$ cocoa incident evaluate \
  --org \
  --repo \
  --git-provider \
  --git-token-path \
  --filePath

cocoa locker コマンド

エビデンス・ロッカーは、 GitHub (Enterprise) 上の Git リポジトリーです。 Git プロバイダーは、 --git-provider (デフォルトでは github ) を使用して指定できます。 どちらのプロバイダーの場合も、認証が必要です。 GitHub では、 GHE_TOKEN 環境変数または --git-token-path フィールドを設定します。 のためにGitHub,また、GitHubインスタンスが見つかったら、 GH_URL 環境変数または --git-api-url フィールドですが、デフォルトは https://github.ibm.com

エビデンス・ロッカー・リポジトリーの名前は、 --org および --repo を使用するか、 EVIDENCE_LOCKER_REPO_OWNER および EVIDENCE_LOCKER_REPO_NAME 環境変数を使用して設定できます。

デフォルトでは、呼び出しごとに CLI を使用することにより、 Git ロッカーの最新バージョンで作業することが保証されます。 この動作を無効にするには、 COCOA_USE_CACHE0falseno、または n 以外の任意の値に設定します。 この場合、CLI はその内部キャッシュを使用してエビデンスを (はるかに高速で) 検索しますが、結果が失効する可能性があります。

さらに、証拠と添付ファイルを Cloud Object Storageにアップロードして、アーカイブすることもできます。 これは、以下の環境変数が存在する場合に自動的に行われます。

cocoa locker 資産の追加 < URI>

エビデンス・ロッカーに資産を追加します。 資産が存在する場合は、その資産が印刷されます。

オプション:

--org              # (Required) Owner of the evidence locker repo, defaults to `EVIDENCE_LOCKER_REPO_OWNER`
--repo             # (Required) Name of the evidence locker repo, defaults to `EVIDENCE_LOCKER_REPO_NAME`
--type             # Type of the asset ( All types are supported )
--version          # Show version number
--format           # Output format ("id", "json", default: "id")
--git-provider     # Git service provider ("github")
--git-token-path   # Git token path to read the secret from
--git-api-url      # Github API url
--related          # The ID of a related asset (default: [])
--date             # Asset creation date
--details          # Additional asset details, as key=value pairs (default: [])
--origin           # Additional details about the origin of the asset, as key=value pairs (default: [])
--dry-run          # Shows what would be added to the locker (default: false)

ロッカーに何も追加したくない場合に、ロッカーに追加される内容を確認するには、 --dry-run フラグを使用します。

資産のタイプは、 --type フラグで指定できます。

uri パラメーターは、任意の有効な URIにすることができますが、いくつかのフォーマットは特別に扱われます。

  • uri スキームが docker (つまり、 docker:// で始まる) の場合、コマンドは --type=image フラグを想定します。
  • uri スキームが git の場合、またはパスの末尾が .git 接尾部の場合、コマンドは --type=commit フラグを想定します。

typeimage または commit の場合、URI は以下のパターンで一致する必要があります。

  • commit の場合、URI にはフラグメントが なければなりません 。これは、40 文字の 16 進数のコミット・シャ (例えば、 https://github.ibm.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee) でなければ なりません
  • image の場合、URI にはイメージ・ダイジェストを含める 必要があります (例: docker://us.icr.io/foo/bar:v1.2.3@sha256:0000000011111111222222223333333344444444555555556666666677777777)。

typeimage または commit 以外の場合は、 --type フラグを明示的に渡す必要があります。

--details フラグを使用して資産に詳細を追加できます。このフラグは key=value ペアを受け入れます。

資産の起点に関する詳細は、 --origin フラグを使用して提供できます。このフラグは、 key=value ペアを受け入れます。

アセット起点に関する詳細を追加するために、いくつかの環境変数が自動的に取得されます。

  • TOOLCHAIN_CRN の設定は、 --origin toolchain_crn=$TOOLCHAIN_CRN の指定と同じです。
  • PIPELINE_ID の設定は、 --origin pipeline_id=$PIPELINE_ID の指定と同じです。
  • PIPELINE_RUN_ID の設定は、 --origin pipeline_run_id=$PIPELINE_RUN_ID の指定と同じです。

--date フラグは、資産作成日 (デフォルトは現在時刻) をオーバーライドするために使用できます。このフラグは、 Date.parse が受け入れる任意のストリングを受け入れます。

関係するアセットは、 --related フラグを使用して追加できます (関係するアセットが複数ある場合は、このフラグを複数回指定できます)。 アセットは、内部 ID を使用して指定することも、URI を使用して指定することもできます。 関連するすべてのアセット ID (最初のアセットまでのツリー全体) が、アセット json の parents フィールドに追加されます。

デフォルトでは、 id 形式 ( --format フラグ) は、作成されたアセットの内部 ID を出力します。 json 形式を使用すると、資産全体が JSON オブジェクトとして出力されます。

Git コミットを追加するコマンドを実行します。

$ cocoa locker asset add 'https://github.ibm.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee' \
                         --details tag=v1.2.3

出力例:

b5bbbbb55555b5555b555b55b5555bb5b555b5b555bb5b55bbb5555fbbbbb

以下のコマンドを実行して、 Docker イメージを追加します。

$ cocoa locker asset add docker://us.icr.io/foo/bar:v1.2.3@sha256:0000000011111111222222223333333344444444555555556666666677777777 \
                         --origin "job_name=my job" \
                         --related https://github.ibm.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee \
                         --format json

出力例:

{
   "version": "1.1",
   "id": "0000000011111111222222223333333344444444555555556666666677777777",
   "uri": "docker://us.icr.io/foo/bar:v1.2.3@sha256:0000000011111111222222223333333344444444555555556666666677777777",
   "origin": {
    "job_name": "my job",
    "toolchain_crn": "crn:v1:bluemix:public:toolchain:au-syd:a/111111111111c2f2222222222b22a7a63:ac2a22a2-2a2a-2222-aaa2-222aa22a2a2a::",
    "pipeline_run_id": "f333b3bc-3333-3fea-3333-333d3a3b33b3",
    "pipeline_id": "444aaa4a-b4c4-4444-4f4b-aa4444a444a4"
   },
   "details": {
    "registry": "us.icr.io",
    "name": "foo/bar",
    "tag": "v1.2.3",
    "digest": "0000000011111111222222223333333344444444555555556666666677777777"
   },
   "date": "2021-07-15T14:26:06.301Z",
   "type": "image",
   "related": [
    "b5bbbbb55555b5555b555b55b5555bb5b555b5b555bb5b55bbb5555fbbbbb"
   ],
   "parents": [
    "b5bbbbb55555b5555b555b55b5555bb5b555b5b555bb5b55bbb5555fbbbbb"
   ]
}

リリースを追加するコマンドの実行:

$ cocoa locker asset add release:my-app@v1.2.3 \
                         --type generic \
                         --date 2021-06-01T12:00:00 \
                         --related docker://us.icr.io/foo/bar:v1.2.3@sha256:0000000011111111222222223333333344444444555555556666666677777777

出力例:

36d8852458adf44ab236c99beb69d7070d461d39480bc6b8ef7c771bee93cb49%

cocoa locker asset get < URI>

エビデンス・ロッカーから資産を取得します。

オプション:

--org              # (Required) Owner of the evidence locker repo, defaults to `EVIDENCE_LOCKER_REPO_OWNER`
--repo             # (Required) Name of the evidence locker repo, defaults to `EVIDENCE_LOCKER_REPO_NAME`
--type             # Type of the asset
--version          # Show version number
--git-provider     # Git service provider ("github")
--git-token-path   # Git token path to read the secret from
--git-api-url      # Github API url
--format           # Output format ("id", "json", default: "id")

コマンドを実行します。

 cocoa locker asset get release:my-app@v1.2.3 --format json

出力例:

{
   "version": "1.1",
   "id": "36d8852458adf44ab236c99beb69d7070d461d39480bc6b8ef7c771bee93cb49",
   "uri": "release:my-app@v1.2.3",
   "origin": {
    "toolchain_crn": "crn:v1:bluemix:public:toolchain:au-syd:a/111111111111c2f2222222222b22a7a63:ac2a22a2-2a2a-2222-aaa2-222aa22a2a2a::",
    "pipeline_run_id": "f333b3bc-3333-3fea-3333-333d3a3b33b3",
    "pipeline_id": "444aaa4a-b4c4-4444-4f4b-aa4444a444a4"
   },
   "details": {
    "sha": "aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee",
    "repository": "https://github.ibm.com/foo/bar.git",
    "tag": "v1.2.3"
   },
   "date": "2021-07-15T14:26:06.301Z",
   "type": "image",
   "related": ["0000000011111111222222223333333344444444555555556666666677777777"],
   "parents": ["0000000011111111222222223333333344444444555555556666666677777777", "b5bbbbb55555b5555b555b55b5555bb5b555b5b555bb5b55bbb5555fbbbbb"]
}
 cocoa locker asset get docker://us.icr.io/foo/bar:v1.2.3@sha256:0000000011111111222222223333333344444444555555556666666677777777 --format json

出力例:

{
   "version": "1.1",
   "id": "0000000011111111222222223333333344444444555555556666666677777777",
   "uri": "docker://us.icr.io/foo/bar:v1.2.3@sha256:0000000011111111222222223333333344444444555555556666666677777777",
   "origin": {
    "toolchain_crn": "crn:v1:bluemix:public:toolchain:au-syd:a/111111111111c2f2222222222b22a7a63:ac2a22a2-2a2a-2222-aaa2-222aa22a2a2a::",
    "pipeline_run_id": "f333b3bc-3333-3fea-3333-333d3a3b33b3",
    "pipeline_id": "444aaa4a-b4c4-4444-4f4b-aa4444a444a4"
   },
   "details": {
    "sha": "aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee",
    "repository": "https://github.ibm.com/foo/bar.git",
    "tag": "v1.2.3"
   },
   "date": "2021-07-15T14:26:06.301Z",
   "type": "image",
   "related": [],
   "parents": ["b5bbbbb55555b5555b555b55b5555bb5b555b5b555bb5b55bbb5555fbbbbb"]
}
 cocoa locker asset get https://github.ibm.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee --format json

出力例:

{
   "version": "1.1",
   "id": "0000000011111111222222223333333344444444555555556666666677777777",
   "uri": "docker://us.icr.io/foo/bar:v1.2.3@sha256:0000000011111111222222223333333344444444555555556666666677777777",
   "origin": {
    "toolchain_crn": "crn:v1:bluemix:public:toolchain:au-syd:a/111111111111c2f2222222222b22a7a63:ac2a22a2-2a2a-2222-aaa2-222aa22a2a2a::",
    "pipeline_run_id": "f333b3bc-3333-3fea-3333-333d3a3b33b3",
    "pipeline_id": "444aaa4a-b4c4-4444-4f4b-aa4444a444a4"
   },
   "details": {
    "sha": "aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee",
    "repository": "https://github.ibm.com/foo/bar.git",
    "tag": "v1.2.3"
   },
   "date": "2021-07-15T14:26:06.301Z",
   "type": "image",
   "related": [],
   "parents": []
}

Cocoa locker asset summary get < URI>

指定された資産のエビデンス・サマリーをエビデンス・ロッカーから収集します。

オプション:

--scope                   # (Required) Pipeline run ID of the CI piepline where the asset is built
--environment             # (Required) Name of the environment from which evidences are fetched, if the `service-environment` is `pre_prod`       
                            This value must be the same as the `target-environment`. Or, if `service-environment` is `prod`, then this value must be the same as the `source-environment`
--service-environment     # Service environment of the asset get summary in deployed environment
                            (choices: 'pre_prod', 'dev', 'prod',  default: 'pre_prod')
--latest                  # Fetches the latest evidence summary of the asset for the `service-environment`.
                            The summary of the scope passed-in using `--scope` will be excluded. Currently supported for `dev` environment only.                         

コマンドを実行します。

 cocoa locker asset summary get https://github.ibm.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee \
  --scope 11a1aa11-1a11-11a1-aa11-a11a1a1111a1 \
  --environment prod \
  --service-environment prod

コマンドを実行して、渡されたスコープを除いた最新の証拠サマリーを取得します。--scope :

 cocoa locker asset summary get https://github.ibm.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee \
  --scope 11a1aa11-1a11-11a1-aa11-a11a1a1111a1 \
  --environment dev \
  --service-environment dev \
  --latest

cocoa locker 資産リスト < URI>

エビデンス・ロッカーから関係するアセットをリストします。

オプション:

--org              # (Required) Owner of the evidence locker repo, defaults to `EVIDENCE_LOCKER_REPO_OWNER`
--repo             # (Required) Name of the evidence locker repo, defaults to `EVIDENCE_LOCKER_REPO_NAME`
--type             # Type of the asset
--version          # Show version number
--git-provider     # Git service provider ("github")
--git-token-path   # Git token path to read the secret from
--git-api-url      # Github API url
--format           # Output format ("id", "json", default: "id")

コマンドを実行します。

 cocoa locker asset list release:my-app@v1.2.3 --format id --type generic

出力例:

1122211111122222111111111111111111111111111111666661111111111111
2222222222555552222222222222222333333222222222222222222222222222
3333333337777773333333333333333333333333333333344444433333333333

jqと組み合わせた json フォーマットを使用してコマンドを実行します。


 cocoa locker asset list release:my-app@v1.2.3 --format json --type generic | jq -r '.[].uri'

出力例:

release:my-app@v1.2.3
docker://us.icr.io/foo/bar:v1.2.3@sha256:0000000011111111222222223333333344444444555555556666666677777777
https://github.ibm.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee

ココア・ロッカー・エビデンスの追加

エビデンス・ロッカーにエビデンスを追加します。

エビデンス・ロッカーは、フラグを使用して指定できます。 詳しくは、 cocoa locker commands を参照してください。

エビデンスは以下のフラグを使って設定できる:

  • --evidence-type: エビデンスのタイプを識別するストリング (例えば、 com.ibm.unit_test)
  • --evidence-type-version: エビデンス詳細スキーマを識別するストリング (例えば、 1.0.0v2、など)

いくつかのオプション・フラグも指定できます。

  • --date: 証拠作成日 (デフォルトは現在のタイム・スタンプ)。 Date.parse で解析できるストリングを受け入れます。
  • --details: エビデンス詳細は key=value ペアとして指定できます。フラグは複数回指定できます (例えば、 --details result=success --details foo=bar など)。
  • --origin: エビデンスの発信元に関する詳細は、 key=value のペア (例えば、 --origin job_id=123 など) を使用して指定できます。
  • --asset: エビデンスに関連するアセットを (URI または内部 ID によって) 指定します。 cocoa locker asset コマンドを参照してください。 フラグは複数回指定できます。 この資産は既にロッカーに存在している必要があります。
  • --attachment: エビデンスに添付ファイルを指定します。 各添付ファイルは既存のファイルを指す必要があり、各添付ファイル名は固有でなければなりません (つまり、 --attachment a/foo.json --attachment b/foo.json は許可されません)。
  • --attachment-url: エビデンス・ロッカーに既に保管されている添付ファイルの URL を指定します。 各 URL は、重複しないように、固有の添付ファイルを指す必要があります。 このフラグを複数回指定して、複数の URL を含めることができます。
  • --issue: 問題の URL のリスト。これを使用して、検出結果に関連するアクティビティーを追跡できます。 フラグは複数回渡すことができます。
  • --findings-path: このパスを使用して、インシデント・プロセス・コマンドからの出力である JSON 検出結果の配列を渡します。
  • --scope: 複数のソースからの証拠を相関させるために使用できる固有 ID。
  • --comment-on-issues: --issue フラグを使用して、作成されたエビデンスに関する詳細を含むコメントをインシデントの問題に追加します。
    • 問題は github で発生する可能性があるため、プロバイダーは問題の URL から解析されます。
    • すべての問題は同じリポジトリーからのものでなければなりません
    • 問題の URL は、以下のパターンと一致する必要があります。
      • https://<host>/<owner>/<name>/issues/<issue number>- github の場合
    • 問題リポジトリーにアクセスするために必要な環境変数:
      • URL が github の問題を指している場合:
        • GH_URL: オプション。デフォルトは https://github.ibm.com/api/v3
        • GHE_TOKEN

エビデンス JSON での添付ファイルのラベル情報:

エビデンス JSON の各添付ファイル・セクションには、添付ファイルに関するメタデータを保持するためのラベル・プロパティーがあります。 デフォルト値がラベルに割り当てられます。この値は、添付ファイルの入力がファイル・パスであるか、添付ファイルの URL であるかによって異なります。 添付ファイル・パスまたは添付ファイル URL の末尾に ::label=<value> を追加して、カスタム・ラベルを渡します。

例:

  • --attachment path/to/attachment::label=label_name- path/to/attachment 内のファイルを使用して添付ファイルを作成し、ラベル値を label_name に設定します。 ラベルが渡されない場合、デフォルトではファイル名がラベル値として使用されます。

  • --attachment-url url/of/attachment::label=label_name- attachment-url で指定された添付ファイルを使用し、ラベル値を label_name に設定します。 ラベルが渡されない場合、デフォルトではラベル値は空ストリングです。

アセット起点に関する詳細を追加するために、いくつかの環境変数が自動的に取得されます。

  • TOOLCHAIN_CRN の設定は、 --origin toolchain_crn=$TOOLCHAIN_CRN の指定と同じです。
  • PIPELINE_ID の設定は、 --origin pipeline_id=$PIPELINE_ID の指定と同じです。
  • PIPELINE_RUN_ID の設定は、 --origin pipeline_run_id=$PIPELINE_RUN_ID の指定と同じです。

コマンドの動作は、以下のフラグを使用して変更できます。

  • --dry-run: ロッカーに何も追加しませんが、追加される内容を示します。
  • --cache-mode: ドライランに似ています。 実際にはロック要求者に証拠を追加しませんが、ロック要求者に添付ファイル (存在する場合) を追加します。 追加されるエビデンスを表示します。
  • --format: 出力フォーマットを制御します。 id または json (デフォルトでは id )。

以下のコマンドを実行して、 detect-secretsの結果を保存します。

$ cocoa locker evidence add --evidence-type com.ibm.detect_secrets \
                            --evidence-type-version 1.0.0 \
                            --details result=success \
                            --asset https://github.ibm.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee

以下のコマンドを実行して、単体テスト結果を保存します。

$ cocoa locker evidence add --evidence-type com.ibm.unit_test \
                            --evidence-type-version 1.0.0 \
                            --details failure \
                            --asset https://github.ibm.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee
                            --attachment path/to/results/junit.xml \
                            --issue https://github.ibm.com/foo/bar/issues/123 \
                            --findings-path <path/to/file>

以下のコマンドを実行して、エビデンス・ロッカーに既に存在する添付ファイルを使用して新しいエビデンスを作成します。

$ cocoa locker evidence add --evidence-type com.ibm.detect_secrets \
                            --evidence-type-version 1.0.0 \
                            --attachment-url https://github.ibm.com/foo/bar/blob/master/raw/attachments/5aa5555aa55aa55a555aa5a5aa555555aaaa5aa5aa5555a55a5aa5aa5a5aaaaa/content
                            --asset https://github.ibm.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee

以下のコマンドを実行して、単体テストの結果を保存し、添付ファイルにカスタム・ラベルを追加します。

$ cocoa locker evidence add --evidence-type com.ibm.unit_test \
                            --evidence-type-version 1.0.0 \
                            --details success \
                            --asset https://github.ibm.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee
                            --issue https://github.ibm.com/foo/bar/issues/123 \
                            --findings-path <path/to/file> \
                            --attachment path/to/results/junit.xml::label=unit-test

ココア・ロッカーの証拠が < エビデンス ID> を取得

ロッカーから証拠の一部を取得します。

オプション:

--org              # (Required) Owner of the evidence locker repo, defaults to `EVIDENCE_LOCKER_REPO_OWNER`
--repo             # (Required) Name of the evidence locker repo, defaults to `EVIDENCE_LOCKER_REPO_NAME`
--git-provider     # Git service provider ("github")
--version          # Show version number
--git-token-path   # Git token path to read the secret from
--git-api-url      # Github API url
--format           # Output format ("json", default: "json")

コマンドを実行します。

 cocoa locker evidence get 0000000011111111222222223333333344444444555555556666666677777777

出力例:

{
   "id": "0000000011111111222222223333333344444444555555556666666677777777",
   "evidence_type_id": "com.ibm.unit_tests",
   "evidence_type_version": "1.0.0",
   "date": "2024-03-27T16:36:48.167Z",
   "origin": {
     "toolchain_crn": "crn:v1:bluemix:public:toolchain:us-south:a/40111714589c4f7099032529b26a7a63:f0ffdc07-616e-40fa-98d5-2f52d5e8ef4d::",
     "pipeline_id": "b313626a-a612-4c98-ae5c-408af7d7ce58",
     "pipeline_run_id": "cadb83be-f00d-44af-95d0-1b49deb8abb5",
     "pipeline_run_url": "https://cloud.ibm.com/devops/pipelines/tekton/b313626a-a612-4c98-ae5c-408af7d7ce58/runs/cadb83be-f00d-44af-95d0-1b49deb8abb5/code-unit-tests/run-stage/?env_id=ibm:yp:us-south",
     "scope": "82aef875749c6386381a3baff8430df6f5ac2e8434cc91e5287ce65bd71a3985"
   },
   "details": {
     "result": "pending",
     "tool": "jest"
   },
   "issues": [],
   "findings": [],
   "attachments": [
      {
       "hash": "9a841ef856a5de813dbe440b102b9bff3ca1831630292cff7323c557704f386b",
       "url": "https://s3.private.us-south.cloud-object-storage.appdomain.cloud/test/assets/9a841ef856a5de813dbe440b102b9bff3ca1831630292cff7323c557704f386b/index.json",
       "label": "unit-test"
     }
   ],
   "assets": [
     {
       "hash": "7d930918fbb8be80f3a5100f0313c5b2518eba22cc915194cf971d4daf5170be",
       "uri": "https://github.ibm.com/one-pipeline/compliance-app-march-2024.git#be44f38ec9b290d4f3d4931b37910effac346441",
       "url": "https://s3.us-south.cloud-object-storage.appdomain.cloud/cocoa-development/assets/7d930918fbb8be80f3a5100f0313c5b2518eba22cc915194cf971d4daf5170be/index.json"
     }
   ]
}

ココア・ロッカーの証拠の要約 < asset-id>

1 つ以上の資産のエビデンス要約を返します。 コマンド行に資産が指定されていない場合、資産は stdin から読み取られます。

オプション・フラグ:

  • --latest-only: 資産に対してより新しいエビデンスが使用可能な場合、エビデンスを破棄します (true はデフォルトで false に設定されており、この動作を無効にします)
  • --scope: 指定されたスコープのみを持つエビデンスを考慮します ( evidence add --scope を参照)。複数回指定できます。
  • --linked-scope: 指定されたリンク スコープをスコープとして持つ証拠を考慮します。 さらに、返された証拠の概要の linked-scopes プロパティにそれらを追加します。 複数回指定可能。
  • --check-immutable-storage: すべてのエビデンスが Cloud Object Storage バケットにも存在し、少なくとも 365 日の保存期間によって保護されているかどうかを検査します。 要約に com.ibm.immutable_storage エビデンスを追加します。
    • Cloud Object Storage バケットの構成方法については、 cocoa locker のセクションを参照してください。
  • --dry-run: --check-immutable-storage と組み合わせると効果があります。 使用した場合、 com.ibm.immutable_storage のエビデンスは要約にのみ付加されますが、エビデンス・ロッカーにはアップロードされません。
  • --clone-dir:Evidence Repositoryのクローンパスを決定するオプションのパラメータで、デフォルトでは/tmpディレクトリをクローンします
  • --initialized:オプションのフラグで、--clone-dir または /tmp/ が指定された場所にすでにクローンされていると仮定します。
  • --evidences-path:キャッシュに保存されているローカル証拠から要約を作成するために、このフィールドは、すべての証拠が配列に存在するファイルのパスを指定するために使用される。

コマンドを実行します。

$ cocoa locker evidence summary \
    docker://us.icr.io/foo/bar@sha256:1234567812345678123456781234567812345678123456781234567812345678 \
    docker://us.icr.io/baz/quux@sha256:1234567812345678123456781234567812345678123456781234567812345678 \
    --scope 11a1aa11-1a11-11a1-aa11-a11a1a1111a1 \
    --scope 22a2aa22-2a22-22a2-aa22-a22a2a2222a2 \
    --linked-scope 33a3aa33-3a33-33a3-33a3-a33a3a3333a3 \
    --linked-scope 12bqab22-1a23-1a23-1a23-b22a3a2222a3

標準入力からの読み取り例:

$ cat <<EOF | cocoa locker evidence summary
docker://us.icr.io/foo/bar@sha256:1234567812345678123456781234567812345678123456781234567812345678
docker://us.icr.io/baz/quux@sha256:1234567812345678123456781234567812345678123456781234567812345678
EOF

cocoa locker attachment get < attachment-id>

cocoa locker evidence add で以前にアップロードされた添付ファイルを取得します。

オプション:

--org              # (Required) Owner of the evidence locker repo, defaults to `EVIDENCE_LOCKER_REPO_OWNER`
--repo             # (Required) Name of the evidence locker repo, defaults to `EVIDENCE_LOCKER_REPO_NAME`
--git-provider     # Git service provider ("github")
--version          # Show version number
--git-token-path   # Git token path to read the secret from
--git-api-url      # Github API url

以下のコマンドを実行して、添付ファイルをアップロードします。

$ cocoa locker evidence add --evidence-type-id com.ibm.unit_test \
                            --evidence-type-version 1.0 \
                            --details result=success \
                            --attachment path/to/junit.xml::label=unit-test

添付ファイルのアップロードの出力例:

{
   ...
   "attachments": [
    {
      "hash": "9a841ef856a5de813dbe440b102b9bff3ca1831630292cff7323c557704f386b",
      "url": "https://s3.private.us-south.cloud-object-storage.appdomain.cloud/test/assets/9a841ef856a5de813dbe440b102b9bff3ca1831630292cff7323c557704f386b/index.json",
      "label": "unit-test"
    }
   ],
   ...
}

コマンドを実行して添付ファイルを取得する:

 cocoa locker attachment get 5aa5555aa55aa55a555aa5a5aa555555aaaa5aa5aa5555a55a5aa5aa5a5aaaaa

ココア・ロッカー検査

ロッカーの必要な構成と設定を検査します。

現在、構成要件があるのは、 Cloud Object Storage ベースのロッカーのみです。

  • すべてのエビデンスを少なくとも 1 年間保持する必要があるため、 Cloud Object Storage バケットは保存ポリシーによって保護する必要があります。 デフォルトの保存期間は 365 日以上でなければなりません。

詳しくは、 cocoa locker commands を参照してください。

必要な環境変数:

COS_API_KEY=        # Cloud Object Storage API Key
COS_BUCKET_NAME=    # Bucket Name where the evidence will be uploaded in the COS Instance
COS_ENDPOINT=       # The COS API Endpoint matching the region where the bucket is located

コマンドを実行します。

 cocoa locker check --provider='cos'

ココア・ロッカー証拠検査

構成ファイル cocoa locker evidence check に存在するチェックに基づいて、必要なエビデンスを検証します。

必要な環境変数:

オプション:

--org              # (Required) Owner of the evidence locker repo, defaults to `EVIDENCE_LOCKER_REPO_OWNER`
--repo             # (Required) Name of the evidence locker repo, defaults to `EVIDENCE_LOCKER_REPO_NAME`
--git-provider     # Git service provider ("github")
--git-token-path   # Git token path to read the secret from
--git-api-url      # Github API URL
--config-path      # (required) use this path to read the config file of all the required evidence check
--summary-path     # (required) use this path to read the summary file of all the evidences
--pre-deployment   # If present, will check only pre deployment checks, defaults to false
--post-deployment  # If present, will check only post deployment checks, defaults to false
--source           # (Applies to config file version 2) If present, is tupple of branch:region information(with region as optional) which will be used to filter the rules against `source_environments` field.
--target           # (Applies to config file version 2) If present, is tupple of branch:region information(with region as optional) which will be used to filter the rules against `target_environments` field.
--pipeline-run-id  # (Applies to config file version 2) If present, is current pipeline_run_id will be used for checking evidences.

コマンドを実行します。

 cocoa locker evidence check --summary-path `<summary-path>` --config-path `<config-path>` --pre-deployment --post-deployment --source `<source_branch:region>` --target `<target_branch:region>` --pipeline-run-id `<current_pipeline-run-id>`

ココア・ロッカーの証拠公開

証拠を Git および Cloud Object Storage (COS) バックエンド (COS が構成されている場合) に公開します。

cocoa locker evidence publish は、証拠のバッチ処理に使用されます。

COS を構成するために必要な環境変数:

COS_API_KEY=        # Cloud Object Storage API Key
COS_BUCKET_NAME=    # Bucket Name where the evidence will be uploaded in the COS Instance
COS_ENDPOINT=       # The COS API Endpoint matching the region where the bucket is located

オプション:

  --version         # Show version number                                
  --help            # Show help                                          
  --git-provider    # Git provider of the evidence locker ("github", "gitlab")
  --org             # (Required) Owner of the evidence locker repo, defaults to `EVIDENCE_LOCKER_REPO_OWNER`            
  --repo            # (Required) Name of the evidence locker repo, defaults to `EVIDENCE_LOCKER_REPO_NAME`              
  --git-token-path  # Git token path to read the secret from              
  --git-api-url     # Git API URL                                         
  --evidences-path  # (Required) Use this path to read the evidences to be published
  --commit-message  # (Optional) Commit message suffix to be used for the commit to the git repository

コマンドを実行します。

$ cocoa locker evidence publish \
      --org=<github-organization> \
      --repo=<github-repo-name> \
      --git-provider github \
      --evidences-path <path/to/file>

cocoa tekton コマンド

cocoa tekton get-pipeline-logs

パイプラインの実行のすべてのステップについてログ・ファイルを作成し、ディレクトリーに保存します。 環境変数 (PIPELINE_IDPIPELINE_RUN_ID) を使用するか、明示的なフラグ (--pipeline-id--pipeline-run-id) で環境変数をオーバーライドします。 ログ・ファイルは、 --task-name フラグと --step-name フラグを指定することによっても、タスクごとおよびステップごとのレベルで取得できます。

--task-name が指定されている場合、コマンドは、指定されたタスク名の各ステップのログ・ファイルをプルして作成しようとします。

--step-name--task-name に指定されている場合、このコマンドは、指定された task-name. --step-name の特定のステップのログ・ファイルを作成します。 --task-name を指定しないと、無効なコマンド・シグニチャーになります。

オプション:

-o --output-dir       # (Required) Specifies the directory where the logs will be saved
   --pipeline-id      # ID of the pipeline
   --pipeline-run-id  # ID of the pipeline run
-u --use-task-ref     # (Optional) Can be used to override the default name of the pipeline task to the taskRef, when creating the directory
   --task-name       # (Optional) use task-name to fetch the logs for --task-name
   --step-name       # (Optional) use step-name in conjunction with task-name to fetch the log for --step-name

必要な環境変数:

IBMCLOUD_API_KEY= # IBM Cloud API Token
TOOLCHAIN_REGION= # Region of the toolchain
PIPELINE_ID=      # Can be used instead of '--pipeline-id option
PIPELINE_RUN_ID=  # Can be used instead of '--pipeline-run-id option

次のコマンドを実行します。

$ cocoa tekton get-pipeline-logs \
   --output-dir=<output-dir> \
   --pipeline-id=<pipeline-id> \
   --pipeline-run-id=<pipeline-run-id> \
   --use-task-ref

cocoa changelog コマンド

cocoa changelog

このコマンドは非推奨であり、 2.0.0で削除されます。

cocoa changelog は、Git Repos and Issue Tracking ではサポートされていません。

レポ内の2つのリビジョン間の変更履歴を標準出力に出力します。

オプション:

--org   # Defaults to GHE_ORG env variable, github organization
--repo  # Defaults to GHE_REPO env variable, name of the github repository

必要な環境変数:

GHE_TOKEN=  # Github Enterprise API Token (Required)
GHE_ORG=    # The owner of the repository (optional, when --org is not provided)
GHE_REPO=   # The repository name (optional, when --repo is not provided)

このコマンドには、次の 3 つの使用方法があります。

  • --from オプションと --to オプションの両方が指定された場合は、範囲内のコミットを検査する。

オプション:

--from  # git commit hash to calculate the changes from
--to    # git commit hash to calculate the changes to

次のコマンドを実行します。

$ cocoa changelog \
   --org=<github-organization> \
   --repo=<github-repo-name> \
   --from=<commit-hash-to-calculcate-changes-from> \
   --to=<commit-hash-to-calculate-changes-to>
  • --pr オプションが指定された場合は、特定のプル要求に属するコミットをすべて含める。

オプション:

--pr # pull request number from which the changelog is calculated

次のコマンドを実行します。

$ cocoa changelog \
   --org=<github-organization> \
   --repo=<github-repo-name> \
   --pr=<pull-request-number>
  • 上記の情報が指定されていない場合は、現在マージ済みのプル要求の変更を変更ログに含める。

次のコマンドを実行します。

$ cocoa changelog \
   --org=<github-organization> \
   --repo=<github-repo-name>

cocoa コメント・コマンド

ココア・コメント追加

GitHubで問題またはプル要求にコメントを追加します。

オプション:

--content           	# (Required) The content to be added as comment to issue or pr
--id       		# (Required) The issue number or pull request number
--type             	# (Optional) The type (issue or pr), default is issue
--org               	# The git repo org
--repo              	# The git repo name
--git-provider     	# (Optional) Git service provider [github]
--git-token-path    	# (Optional) Github Token's path
--git-api-url       	# (Optional) Github API url

必要な環境変数:

GHE_ORG=                    # Can be used instead of --org (either the option or the variable is required)
GHE_REPO=                   # Can be used instead of --repo (either the option or the variable is required)

必要な環境変数(使用している場合)GitHub:

GHE_TOKEN=    # Github Enterprise API Token (Optional if you are using --git-token-path)

github を使用している場合は、 --git-token-path フィールドを使用して GitHub トークンを設定し、 --git-api-url フィールドを使用して環境変数 GHE_TOKEN および GH_URL の代わりに GitHub Enterprise API URL を設定します。 環境プロパティーとコマンド行パラメーターの両方が指定されている場合は、 --git-token-path--git-api-url が優先されます。

次のコマンドを実行します。

$ cocoa comment add --id 1 \
                    --content "This is a test comment" \
                    --type pr \
                    --git-provider github \
                    --org <github-organization> \
	  				--repo <github-repo-name>