[英]I am trying to add Bandit to my gitlab-ci.yml file but on executing an egrep command the job fails without any error message
.gitlab-ci.yml 文件在下面,這是我執行測試階段的部分。 運行 egrep 命令后,它只是失敗,沒有任何錯誤消息
stage: test
image:
name: python:latest
entrypoint:
- "/usr/bin/env"
- "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
script:
- ls -la
- python --version
- pip3 install --upgrade pip
- pip3 install --upgrade setuptools
- pip3 install bandit
- bandit ../lambda_function_code -r | tee ./output_test.log
- egrep "Severity:\sHigh" output_test.log | wc -l
- |
if [ $severity_count -neq 0 ]; then
exit 1
fi
- echo ${TF_ROOT}
管道輸出(egrep commaned 成功運行,但之后沒有任何東西運行並且管道失敗)
我正在嘗試從 bandit 命令生成的 output_test.log 文件中查找具有 Severity: High/medium/low 的文本。
我在這里做錯了什么?
您想存儲egrep "Severity:\sHigh" output_test.log | wc -l
的輸出 egrep "Severity:\sHigh" output_test.log | wc -l
到$severity_count
變量中。
嘗試以下操作:
stage: test
image:
name: python:latest
entrypoint:
- "/usr/bin/env"
- "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
script:
- ls -la
- python --version
- pip3 install --upgrade pip
- pip3 install --upgrade setuptools
- pip3 install bandit
- bandit ../lambda_function_code -r | tee ./output_test.log
- severity_count=$(egrep "Severity:\sHigh" output_test.log | wc -l)
- |
if [ $severity_count -neq 0 ]; then
exit 1
fi
- echo ${TF_ROOT}
命令周圍的$(...)
告訴腳本評估括號內的 shell 語句。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.