Bitbucket Pipelines报错apt-get: command not found,需安装jq
解决Bitbucket Pipelines中apt-get命令找不到的问题
你遇到的bash: apt-get: command not found错误,根源是Validate Task Definitions步骤使用的atlassian/pipelines-awscli镜像基于Alpine Linux——这个发行版的包管理器是apk,而非Debian/Ubuntu系列的apt-get,所以用apt-get自然找不到命令。
下面给你两种可行的解决办法:
办法一:改用Alpine的apk包管理器安装jq
直接替换步骤里的安装命令,把apt-get相关命令换成apk的用法:
修改后的Validate Task Definitions步骤配置如下:
- step: name: Validate Task Definitions image: atlassian/pipelines-awscli script: - source .env.common - apk update - apk add --no-cache jq - eval $(aws ecr get-login --region ${AWS_DEFAULT_REGION} --no-include-email) artifacts: - .env.common
--no-cache参数可以避免缓存包索引,减少镜像体积和运行时间。
办法二:换用自带jq的镜像
如果不想折腾包管理器,可以直接使用Bitbucket的默认镜像atlassian/default-image:latest,这个镜像已经预装了jq、AWS CLI等常用工具,省去安装步骤:
修改后的步骤配置:
- step: name: Validate Task Definitions image: atlassian/default-image:latest script: - source .env.common - eval $(aws ecr get-login --region ${AWS_DEFAULT_REGION} --no-include-email) artifacts: - .env.common
这样直接就能用jq,不需要额外安装。
内容的提问来源于stack exchange,提问作者power-cut
相关产品推荐
相关产品推荐

