我正在尝试使用bitbucket管道设置我的cicd管道,我需要在其中一个步骤中安装jq
以格式化文件。但是,我得到bash: apt-get: command not found
错误。
下面是我的bitbucket管道
pipelines:
custom: # Pipelines that can only be triggered manually
push-build-to-ecr:
- step:
name: Build & Push Image
services:
- docker
caches:
- docker
script:
- export SERVICE_NAME=my-node-service
- export SERVICE_BRANCH=$BITBUCKET_BRANCH
- export TAG_LATEST=$SERVICE_BRANCH-latest
- printenv > .env.common
# Remove lines with spaces in env file
- sed -i -e '/ /d' .env.common
- docker build --tag $SERVICE_NAME:$TAG_LATEST --target=production-stage .
- docker images
- pipe: atlassian/aws-ecr-push-image:2.0.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: $SERVICE_NAME
TAGS: $TAG_LATEST
artifacts:
- .env.common
- step:
name: Validate Task Definitions
image: atlassian/pipelines-awscli
script:
- source .env.common
- apt-get update
- apt-get install -y jq
- eval $(aws ecr get-login --region ${AWS_DEFAULT_REGION} --no-include-email)
artifacts:
- .env.common
- step:
name: Deploy to ECS
script:
- echo "Deploy to ECS"
1条答案
按热度按时间2ic8powd1#
有些docker镜像不是来自Debian镜像,而是来自其他发行版,比如Alpine,你正在使用的
atlassian/pipelines-awscli
就是这种情况。你不能假设docker镜像中存在特定的包管理器。你甚至不能假设任何包管理器的存在!
就这么做
专业提示
1
atlassian/pipelines-awscli
已过时,已弃用amazon/aws-cli
,由Amazon维护,请参阅https://hub.docker.com/r/atlassian/pipelines-awscli请注意,
amazon/aws-cli
既不支持apt
,也不支持apk
,而是支持yum
,因此您应该这样做:二
任何
aws-cli
子命令都可以通过--query
选项从JMESPath的响应中提取值,因此它几乎与jq
一样强大,以至于jq
通常只是在缺乏意识的情况下安装的。参见https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-filter.html#cli-usage-filter-client-side