返回列表 发布新帖

CI/CD流水线某个任务失败想回滚代码请问如何实现

558 2
发表于 2024-5-14 16:10:54 | 显示全部楼层 阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×

如题

回复

使用道具 举报

评论2

ffliLv.7 发表于 2024-5-14 16:43:30 | 显示全部楼层
stages:
  - test

test1:
  stage: test
  script:
    - echo job

test2:
  stage: test
  script:
    - echo roll
  when: on_failure
  needs:
    - test1

test2 任务只会在 test1 失败后运行,这时候就可以在 test2 中实现回滚操作
回复

使用道具 举报

Chao楼主Lv.1 发表于 2024-5-14 17:29:08 | 显示全部楼层
rollback_job:
  stage: rollback
  tags:
    - 'git'
  only:
    - master
  script:
    - current_commit_id=$(git rev-parse HEAD)
    - echo $current_commit_id
    - 'git checkout master'
    - 'git revert $current_commit_id'
    - 'git push'
最后一个执行gitPush命令  结果报错,下面是报错信息:
fatal: unable to access 'http://gitlab-ci-token:[MASKED]@xxx.xxx.xx.x:8888/xxxxxxxx/test_sno.git/': The requested URL returned error: 403     请问这是啥原因啊?有没有解决办法
回复

使用道具 举报

意见建议

Email:forum@gitlab.cn
  • 关注公众号
  • 添加专业顾问
Copyright © 2001-2024 极狐GitLab论坛 版权所有 All Rights Reserved. 鄂ICP备2021008419号-1|鄂公网安备42018502006137号
关灯 快速发帖
扫一扫添加专业顾问
返回顶部
快速回复 返回顶部 返回列表