Gitlab-ci.yml 创建 merge 请求

标签 git gitlab gitlab-ci gitlab-api

我在 DEV 分支中运行了以下 gitlab-ci.yml 文件,目标也是 DEV。由于我无法将 TARGET 指向 MASTER,因此不会创建自动 MR。我想知道是否可以在 gitlab-ci 脚本本身中创建 merge 请求。

dev:
  stage: deploy
  script:
    - url_host=`git remote get-url origin | sed -e "s/https:\/\/gitlab-ci-token:.*@//g"`
    - git remote set-url origin "https://gitlab-ci-token:${CI_TAG_UPLOAD_TOKEN}@${url_host}"
    - databricks workspace export_dir -o /mynotebooks.
    - git add .
    - git commit -m 'Add notebooks to Repo' -a || true
    - git push origin HEAD:dev
  tags:
    - test

我已经搜索并引用了我的网站,但看不到有关以编程方式创建 merge 请求的任何注释。

这个想法是各种开发人员正在开发数据砖集群,并且 gitlab 计划定期运行。更改将被推送到 DEV 分支,并将使用 merge 请求推送到 MASTER 分支。

我想知道这个 MR 创建是否可以自动化。请对 GITLAB 不熟悉。

谢谢。

最佳答案

您可以使用 git push 选项在 Gitlab 中创建一个 MR。

要创建 MR 以使用 git 将 dev merge 到 master 中,请运行以下命令

git push origin HEAD:dev -o merge_request.create -o merge_request.target=master 

阅读更多关于 Gitlab 的 push options for merge requests .

关于Gitlab-ci.yml 创建 merge 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58322235/

相关文章:

git - GitHub : "remote: This repository moved. Please use the new location" 中重命名的 repo 出错

git - Visual Studio 2013 git 客户端 - 强制推送

raspberry-pi - 覆盆子pi上kubernetes上的gitlab-runner-找不到容器 “helper”

docker - 如何将环境变量传递给gitlab ci cd中的docker run

android - 使用 Gitlab CI 生成 Android 构建

gitlab:运行者离线,最后一次联系是在几个小时前

git - 我们如何为特定的远程运行 git status?

git - 有没有办法列出 Git 项目中的所有添加项(曾经)?

git fetch --unshallow 给出 :"fatal: --unshallow on a complete repository does not make sense"错误

linux - git ssh 要求 gitlab 提供密码