如何将bc添加到bitbucket CI?

时间:2019-01-26 21:39:50

标签: bitbucket sh bitbucket-pipelines bc

我正在将pylint添加到Bitbucket CI。我决定使用自定义脚本。

bitbucket-pipeline.yml如下:

image: python:3.6.2

pipelines:
  default:
    - step:
        caches:
          - pip
        script:
          - set -e
          - pip install -r requirements.txt
          - pip install --upgrade urllib3
          - nosetests project1/test
          - nosetests project2/test
          - pylint --rcfile=.pylintrc --output-format=text project1/report | tee pylint.txt
          - score=$(sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' pylint.txt)
          - apt-get install bc
          - sh pylint_score.sh

检查pylint得分(pylint_score.sh)的脚本如下:

#!/usr/sh

score=$(sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' pylint.txt)

echo "Pylint score was $score"

threshhold=$(echo "$score>8.0" | bc)

echo "$threshhold"

if [ $threshhold -eq 0 ]
then
    exit 1
fi

exit 0

我得到的错误:

  

E:无法找到包bc

如何将bc安装到Bitbucket CI中,或者有任何解决方法可以完全不用bc来工作?

最初,我研究了不同的解决方案,但似乎没有一个开箱即用的解决方案,也没有一个所有人都实现的“最佳实践”。因此,我采用了自定义实现。

1 个答案:

答案 0 :(得分:0)

要解决我的问题,我发现了Bitbucket ticket

bitbucket-pipeline.yml中:

apt-get install bc行应修改为

apt-get update && apt-get install -y bc

,或者在某些情况下为

apt-get update && apt-get install -y --no-install-recommends bc

相关问题