如何从 gitlab CI 管道中推送到仓库? [英] How do I push to a repo from within a gitlab CI pipeline?

查看:18
本文介绍了如何从 gitlab CI 管道中推送到仓库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 CI 管道中,我正在生成一个工件 public/graph.png,它可以可视化我的代码的某些方面.在后面的步骤中,我想从 CI 管道中将其提交给 repo.这是 .gitlab-ci.yml 的相关部分:

In my CI pipeline I am generating an artifact public/graph.png that visualises some aspect of my code. In a later step I want to commit that to the repo from within the CI pipeline. Here's the pertinent part of .gitlab-ci.yml:

commit-graph:
  stage: pages
  script:
    - git config user.email "cipipeline@example.com"
    - git config user.name "CI Pipeline"
    - cd /group/project
    - mv public/graph.png .
    - git add graph.png
    - git commit -m "committing graph.png [ci skip]"
    - echo $CI_COMMIT_REF_NAME
    - git push origin HEAD:$CI_COMMIT_REF_NAME

当管道在 gitlab 中运行时失败:

When the pipeline runs within gitlab it fails with:

$ git config user.email "cipipeline@dhgitlab.dunnhumby.co.uk"
$ git config user.name "CI 管道"
$ cd/组/项目
$ mv public/graph.png .
$ git add graph.png
$ git commit -m "提交 graph.png [ci 跳过]"
[分离 HEAD 22a50d1] 提交 graph.png [ci 跳过]
1 个文件已更改,0 个插入 (+),0 个删除 (-)
创建模式 100644 graph.png
$ 回声 $CI_COMMIT_REF_NAME
jamiet/我的分公司
$ git push origin HEAD:$CI_COMMIT_REF_NAME
致命:无法访问'https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@example.com/group/project/project.git/':服务器证书验证失败.CAfile:/etc/ssl/certs/ca-certificates.crt CRLfile:无

$ git config user.email "cipipeline@dhgitlab.dunnhumby.co.uk"
$ git config user.name "CI Pipeline"
$ cd /group/project
$ mv public/graph.png .
$ git add graph.png
$ git commit -m "committing graph.png [ci skip]"
[detached HEAD 22a50d1] committing graph.png [ci skip]
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 graph.png
$ echo $CI_COMMIT_REF_NAME
jamiet/my-branch
$ git push origin HEAD:$CI_COMMIT_REF_NAME
fatal: unable to access 'https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@example.com/group/project/project.git/': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

不确定我做错了什么,并且对 SSL 了解不足,无法理解该错误.谁能给点建议?

Not sure what I'm doing wrong and don't know enough about SSL to understand that error. Can anyone advise?

顺便说一句,我们自己托管 gitlab.

We are hosting gitlab ourselves by the way.

推荐答案

解决了.在推送之前发出 git config --global http.sslverify "false" 解决了该特定问题(它暴露了另一个问题,但这是另一个线程:))

Solved it. Issuing git config --global http.sslverify "false" prior to the push solved that particular problem (it exposed another problem but that's for another thread :) )

这篇关于如何从 gitlab CI 管道中推送到仓库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆