将文件添加到 CI 管道中的现有分支
我正在编写一个通过 CI 添加文档的脚本。我有一个主存储库,我想将新文档推送到其中,因此需要创建一个新分支并在其中添加这些更改。
- name: push gitlab documentation
shell: |
git init
git checkout -b newdocs
git remote add origin https://gitlab-ci-token:{{ gitlab_token }}@{{gitlab.relative_url}}/{{create_repo_response.project.path_with_namespace}}.git
git config pull.ff only
git add .
git commit -m "adding new documentation"
git push -u origin master
我认为 git push
命令是我遇到问题的地方。
stderr": "切换到新分支 'newdocs'\n错误:src refspec master 不匹配任何\n错误: 无法将一些引用推送到 'sample_git_url.git'", "stderr_lines": ["切换到新分支 'newdocs'", "错误: src refspec master 与任何内容都不匹配", "错误: 未能将一些引用推送到“sample_git_url.git””]
我的最终目标是将我的文档推送到master,但在推送时遇到问题。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以看到
git clone
/git switch
的示例(Git 2.23+,git checkout
否则)/git push
在 :href="https://gitlab.eox.at/vs/scheduler/-/blob/cb9d0a367d23104068a27152340dc89578889761/.gitlab-ci.yml#L57-78" rel="nofollow noreferrer">此 可以根据您的情况进行调整,并以这种方式推送您的文档。
You can see an example of
git clone
/git switch
(Git 2.23+,git checkout
otherwise)/git push
in this pipeline script:You can adapt it to your case, and push your docs that way.