我希望阻止新程序员使用管道将包含console.log的代码推送到Bitbucket。我该怎么做呢?
发布于 2017-10-18 19:49:29
假设阻止推送并不太重要,但只要确保在遇到console.log()时构建失败就足够了,那么您可以实现一个脚本步骤来处理代码库。我自己也在用Bb Pipeline做一些类似的事情,包括console.log和debugger。
基本的方法看起来像这样:
foundfiles=$(fgrep -rli "console.log" --include='*.js' $BITBUCKET_CLONE_DIR/path/to/files)
result="$?"
if [ "$result" = "0" ]
then
echo "Found in $foundfiles"
exit 1
fi然后,包含上述代码的Bash脚本将由您的管道运行,如果找到console.log,该脚本将失败。
https://stackoverflow.com/questions/41118575
复制相似问题