我有一个文件夹文件trivy-offline.db.tgz,我想复制它并将它解压到码头,而CI正在运行。
project directory is - /builds/test/eval-trivy-3
gitlab-ci.yml
container_scanning:
stage: test
image:
name: $CI_REGISTRY/devops/trivy/trivy:0.20.1
entrypoint: [""]
variables:
GIT_STRATEGY: none
TRIVY_USERNAME: "$CI_REGISTRY_USER"
TRIVY_PASSWORD: "$CI_REGISTRY_PASSWORD"
TRIVY_AUTH_URL: "$CI_REGISTRY"
FULL_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
script:
- echo "the project directory is - $CI_PROJECT_DIR"
- trivy --version
- time trivy image --clear-cache
- <cp file to this docker>
- <extract file to path>发布于 2021-10-20 11:01:46
要解决的第一个问题是,您正在使用的trivy容器中有哪些工具可用,您内部是否有可用的tar。
通过tar提取的命令是安静的、简单的tar -xzf <file>。
GitLab CI通常已经在检查您的存储库了,因此文件应该已经就位了,并且不需要特别的照顾。
备选案文1:可用tar
container_scanning:
# ...
script:
- echo "the project directory is - $CI_PROJECT_DIR"
- trivy --version
- time trivy image --clear-cache
- tar -xzf trivy-offline.db.tgz变式2:未在映像中的tar
您可以对包含tar的任何其他图像进行预步骤,并使用该图像提取该步骤。
extract-trivy-db:
# ...
script:
- tar -xzf trivy-offline.db.tgz
artifacts:
paths:
- trivy-offline.db
container_scanning:
# ...
needs: ["extract-trivy-db"]
script:
- echo "the project directory is - $CI_PROJECT_DIR"
- trivy --version
- time trivy image --clear-cachehttps://stackoverflow.com/questions/69639670
复制相似问题