简体   繁体   中英

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. Since i couldnt point the TARGET as MASTER, there is no automatic MR getting created. I would like to know if its possible to create a merge request in the gitlab-ci script itself.

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. The changes would be pushed to DEV branch and will be pushed to MASTER branch using the Merge requests.

I would like to know if this MR creation can be automated. NEW TO GITLAB please.

Thanks.

You can create a MR in Gitlab using git push options.

To create a MR to merge dev into master using git, run the following command

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

Read more about Gitlab's push options for merge requests .

There is actually a better programable way to create MR.

Gitlab has its official Gitlab API you can access to create/update/delete almost anything. Of course doing those HTTP requests by yourself will be tedious. Try use the python library for gitlab to do what you want. You can literally make anything programmable!

Specifically to deal with MR, you can look at this chapter .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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