简体   繁体   English

在未找到任何更改的情况下如何使用CircleCI进行语义发布失败

[英]How to make semantic-release with CircleCI fail on no changes found

I have setup a CircleCI job to run semantic-release, but I would like CircleCI to fail when no changes are found. 我已经设置了CircleCI作业以运行语义释放,但是我希望CircleCI在找不到任何更改时失败。 ie when semantic-release outputs: 即,当语义释放输出时:

There are no relevant changes, so no new version is released 没有相关的更改,因此没有发行新版本

CircleCi snippet for the runline. Runline的CircleCi代码段。

  - run:
      name: Semantic Release
      command: npm run semantic-release

Good question. 好问题。 I haven't tested this and I don't know Node.js well in order to quickly test but here's my suggestion. 我还没有测试过,并且我不太了解Node.js以便快速测试,但这是我的建议。

grep returns an exit code of 0 if it finds something and 1 if it doesn't. 如果找到某项,则grep返回退出代码0否则未返回1 Any exit code other than 0 means a failure to CircleCI. 0以外的任何退出代码均表示CircleCI失败。 Grep's -q flag means quiet, don't output text and the && means only run if the previous command passes. Grep的-q标志表示安静,不输出文本, &&表示仅在前面的命令通过时运行。 So, this might work for you: 因此,这可能对您有用:

  - run:
      name: Semantic Release
      # Fail if there are no changes
      command: npm run semantic-release | grep -q "There are no relevant changes, so no new version is released." && exit 1

Again, I haven't personally tested it so I don't know how semantic-release outputs things but this might work. 同样,我还没有亲自测试过它,所以我不知道semantic-release是如何输出事物的,但这可能有用。

semantic-release does not errors out in the case of no release on purpose. 在没有故意释放的情况下,语义释放不会出错。

If you add a commit that doesn't warrant a release (for example a commit that modify a comment in the code or the code formatting) you don't want your CI to fail. 如果添加的提交不能保证发布(例如,修改代码或代码格式中的注释的提交),则您不希望CI失败。

In short, no making a release when no release is needed is a not an error case, therefore the CI should not errors out. 简而言之,在不需要释放时不进行释放不是错误情况,因此CI不应出错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM