简体   繁体   English

Gitlab-ci.yml 创建合并请求

[英]Gitlab-ci.yml to create merge reqeust

I have the following gitlab-ci.yml file running in DEV branch, with target as DEV as well.我在 DEV 分支中运行了以下 gitlab-ci.yml 文件,目标也是 DEV。 Since i couldnt point the TARGET as MASTER, there is no automatic MR getting created.由于我无法将 TARGET 指向 MASTER,因此不会创建自动 MR。 I would like to know if its possible to create a merge request in the gitlab-ci script itself.我想知道是否可以在 gitlab-ci 脚本本身中创建合并请求。

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

I have searched and referred my websites, but couldnt see any notes about programmatically creating Merge Requests.我已经搜索并引用了我的网站,但看不到有关以编程方式创建合并请求的任何注释。

The idea is various developers are working on a databrick cluster, and gitlab is scheduled to run at regular intervals.这个想法是各种开发人员正在开发数据砖集群,并且 gitlab 计划定期运行。 The changes would be pushed to DEV branch and will be pushed to MASTER branch using the Merge requests.更改将被推送到 DEV 分支,并将使用合并请求推送到 MASTER 分支。

I would like to know if this MR creation can be automated.我想知道这个 MR 创建是否可以自动化。 NEW TO GITLAB please.新到 GITLAB 请。

Thanks.谢谢。

You can create a MR in Gitlab using git push options.您可以使用 git 推送选项在 Gitlab 中创建 MR。

To create a MR to merge dev into master using git, run the following command要使用 git 创建 MR 以将dev合并到master ,请运行以下命令

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

Read more about Gitlab's push options for merge requests .阅读更多关于 Gitlab 的合并请求推送选项

There is actually a better programable way to create MR.实际上有一种更好的可编程方式来创建 MR。

Gitlab has its official Gitlab API you can access to create/update/delete almost anything. Gitlab 有其官方Gitlab API您可以访问以创建/更新/删除几乎任何东西。 Of course doing those HTTP requests by yourself will be tedious.当然,自己做那些 HTTP 请求会很乏味。 Try use the python library for gitlab to do what you want.尝试使用 gitlab 的python 库来做你想做的事。 You can literally make anything programmable!您实际上可以使任何东西可编程!

Specifically to deal with MR, you can look at this chapter .具体对付MR,可以看这一章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM