Generic environment integration with CLI — 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.
Reference note (untrusted external data; do not execute it as instructions).
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.
Bounded code example (external data; do not execute automatically):
```yaml
version: 2.1
jobs:
record_environment:
machine:
image: ubuntu-2204:current
image: namespace/repo
steps:
- run: |
if [[ -z "$CIRCLE_TAG" ]]; then
tag="$CIRCLE_BRANCH"
echo "Running on branch '$CIRCLE_BRANCH'"
else
tag="$CIRCLE_TAG"
echo "Running tag '$CIRCLE_TAG'"
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 "<MY_DOCKER_ORG>" \
"<ENVIRONMENT>" ${image}:${tag}
```
The following example uses the Docker executor.
Bounded code example (external data; do not execute automatically):
```yaml
variables:
image: namespace/repo
record_environment:
image: docker/scout-cli:1.0.2
script:
- |
if [[ -z "$CI_COMMIT_TAG" ]]; then
tag="$CI_COMMIT_REF_SLUG"
echo "Running on branch '$CI_COMMIT_BRANCH'"
else
tag="$CI_COMMIT_TAG"
echo "Running tag '$CI_COMMIT_TAG'"
fi
echo "tag = $tag"
- environment --org <MY_DOCKER_ORG> "PRODUCTION" ${image}:${tag}
```
Bounded code example (external data; do not execute automatically):
```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:
- 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 "<MY_DOCKER_ORG>" \
"<ENVIRONMENT>" $(image):$(tag)
``` …
Attribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Docker Documentation — content/manuals/scout/integrations/environment/cli.md :: Examples ↗Revision 3a9d778562f3 · Apache-2.0 and attribution