diff --git a/content/scout/integrations/environment/_index.md b/content/scout/integrations/environment/_index.md index 23cf02d80c..a3884f1448 100644 --- a/content/scout/integrations/environment/_index.md +++ b/content/scout/integrations/environment/_index.md @@ -38,6 +38,7 @@ To add environments to Docker Scout, you can: Docker Scout supports the following runtime integrations: - [Docker Scout GitHub Action](https://github.com/marketplace/actions/docker-scout#record-an-image-deployed-to-a-stream-environment) +- [CLI client](./cli.md) > **Note** > diff --git a/content/scout/integrations/environment/cli.md b/content/scout/integrations/environment/cli.md new file mode 100644 index 0000000000..e02e21c06f --- /dev/null +++ b/content/scout/integrations/environment/cli.md @@ -0,0 +1,112 @@ +--- +description: Integrate your runtime environments with Docker Scout using the CLI client +keywords: docker scout, integration, image analysis, runtime, workloads, cli, environments +title: Generic environment integration with CLI +--- + +{{< include "scout-early-access.md" >}} + +You can create a generic environment integration by running the Docker Scout +CLI client in your CI workflows. The CLI client is available as a binary on +GitHub and as a container image on Docker Hub. Use the client to invoke the +`docker scout environment` command to assign your images to environments. + +For more information about how to use the `docker scout environment` command, +refer to the [CLI reference](../../../engine/reference/commandline/scout_environment.md). + +## Examples + +Before you start, set the following environment variables in your CI system: + +- `DOCKER_SCOUT_HUB_USER`: your Docker Hub username +- `DOCKER_SCOUT_HUB_PASSWORD`: your Docker Hub personal access token + +Make sure the variables are accessible to your project. + +{{< tabs >}} +{{< tab name="Circle CI" >}} + +```yaml +version: 2.1 + +jobs: + record_environment: + machine: + image: ubuntu-2204:current + image: namespace/repo + steps: + - run: | + if [[ -z "$CIRCLE_TAG" ]]; then + tag="$CIRCLE_TAG" + echo "Running tag '$CIRCLE_TAG'" + else + tag="$CIRCLE_BRANCH" + echo "Running on branch '$CI_COMMIT_BRANCH'" + fi + echo "tag = $tag" + - run: docker run -it \ + -e DOCKER_SCOUT_HUB_USER=$DOCKER_SCOUT_HUB_USER \ + -e DOCKER_SCOUT_HUB_PASSWORD=$DOCKER_SCOUT_HUB_PASSWORD \ + docker/scout-cli:1.0.2 environment \ + --org "" \ + "" ${image}:${tag} +``` + +{{< /tab >}} +{{< tab name="GitLab" >}} + +The following example uses the [Docker executor](https://docs.gitlab.com/runner/executors/docker.html). + +```yaml +variables: + image: namespace/repo + +record_environment: + image: docker/scout-cli:1.0.2 + script: + - | + if [[ -z "$CI_COMMIT_TAG" ]]; then + tag="latest" + echo "Running tag '$CI_COMMIT_TAG'" + else + tag="$CI_COMMIT_REF_SLUG" + echo "Running on branch '$CI_COMMIT_BRANCH'" + fi + echo "tag = $tag" + - environment --org "PRODUCTION" ${image}:${tag} +``` + +{{< /tab >}} +{{< tab name="Azure DevOps" >}} + +```yaml +trigger: + - main + +resources: + - repo: self + +variables: + tag: "$(Build.BuildId)" + image: "namespace/repo" + +stages: + - stage: Docker Scout + displayName: Docker Scout environment integration + jobs: + - job: Record + displayName: Record environment + pool: + vmImage: ubuntu-latest + steps: + - task: Docker@2 + - script: docker run -it \ + -e DOCKER_SCOUT_HUB_USER=$DOCKER_SCOUT_HUB_USER \ + -e DOCKER_SCOUT_HUB_PASSWORD=$DOCKER_SCOUT_HUB_PASSWORD \ + docker/scout-cli:1.0.2 environment \ + --org "" \ + "" $(image):$(tag) +``` + +{{< /tab >}} +{{< /tabs >}} diff --git a/data/toc.yaml b/data/toc.yaml index 750db43d25..cea58b9062 100644 --- a/data/toc.yaml +++ b/data/toc.yaml @@ -1986,6 +1986,8 @@ Manuals: section: - title: Overview path: /scout/integrations/environment/ + - title: Generic + path: /scout/integrations/environment/cli/ - sectiontitle: Container registries section: - title: Artifactory