即使代码上传到托管平台检索到错误,Gitlab 作业也会成功

标签 gitlab gitlab-ci continuous-deployment

我有一个 Gitlab CI/CD 管道,可将代码上传到 Facebook 托管平台。

这是舞台:

upload:production:
  stage: upload
  before_script:
    - source ci/upload.sh
  only:
    - master
  script:
    - upload_build_to_facebook production $GAME_ID_PRODUCTION $UPLOAD_ACCESS_TOKEN_PRODUCTION
  environment:
    name: production
    url: https://developers.facebook.com/apps/$GAME_ID_PRODUCTION/instant-games/hosting

尽管作业成功完成,但 $UPLOAD_ACCESS_TOKEN_PRODUCTION 有时会过期,然后我们需要一个新的:

{"error":{"message":"An unexpected error has occurred. Please retry your request later.","type":"OAuthException","is_transient":true,"code":2,"fbtrace_id":"<id>"}}Job succeeded

当我收到这种错误时,有什么方法可以更聪明地让工作失败吗?

谢谢!

最佳答案

为了将作业识别为失败,脚本需要返回非零退出状态。

因此,在您的 upload_build_to_facebook 脚本中,您需要检查上传是否成功。如果没有,您应该exit 1

关于即使代码上传到托管平台检索到错误,Gitlab 作业也会成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55533644/

相关文章:

javascript - 类型错误 : gitlab is not a function

GitLab 项目(存储库)配额

gitlab - 如何获得在 Gitlab 中花费的总时间?

docker - 由于 "no such file or directory"导致 gitlab CI 失败

npm - 从 gitlab 注册表获取 npm 包最新版本

meteor - 通过 Codeship 为 Meteor.com 托管部署脚本

powershell - Azure ARM部署,从powershell传递动态变量

git - 如何 `git clone` 不包括子模块?

git - 是否可以在 gitlab-ci 中将另一个分支构建到另一个目录?

continuous-integration - 根据条件提前终止构建规范,特别是在 git 标签上