Package: gitlab-auto-mr
GitLab Auto MRThis is a simple Python cli script that allows you create MR in GitLab automatically. It is intended to be
used during your CI/CD. However you can chose to use it however you wish.It is based on the script and idea ofRiccardo Padovani,
which he introduced with his blog postHow to automatically create new MR on Gitlab with Gitlab CI.UsageFirst you need to create a personal access token,more information here.
With the scopeapi, so it can create the MR using your API. This access token is passed
to the script with the--private-tokenargument.pipinstallgitlab-auto-mrgitlab_auto_mr--helpUsage:gitlab_auto_mr[OPTIONS]GitlabAutoMRTool.Options:--private-tokenTEXTPrivate GITLAB token, used to authenticate when
calling the MR API.  [required]--source-branchTEXTThe source branch to merge into.  [required]--project-idINTEGERThe project ID on GitLab to create the MR for.
[required]--gitlab-urlTEXTThe GitLab URL i.e. gitlab.com.  [required]--user-idINTEGERThe GitLab user ID(s) to assign the created MR
to.  [required]--reviewer-idINTEGERThe GitLab user ID(s) to assign the created MR
to as reviewer(s).-k,--insecureDo not verify server SSL certificate.-t,--target-branchTEXTThe target branch to merge onto.-c,--commit-prefixTEXTPrefix for the MR title. Default: ‘Draft’.-r,--remove-branchIf set will remove the source branch after MR.-s,--squash-commitsIf set will squash commits on merge.-d,--descriptionTEXTPath to file to use as the description for the
MR.--titleTEXTCustom tile for the MR.-i,--use-issue-nameIf set will use information from issue in branch
name, must be in the form #issue-number, i.e
feature/#6.-a,--allow-collaborationIf set allow, commits from members who can merge
to the target branch.--mr-existsIf set, checks if a merge request exists for the
given ‘source’ and ‘target’ branch and exits
without creating it.--helpShow this message and exit.gitlab_auto_mr--private-token$(private_token)--source-branchfeature/test--project-id5\--gitlab-urlhttps://gitlab.com/--user-id5GitLab CIGITLAB_PRIVATE_TOKENSet a secret variable in your GitLab project with your private token. Name it
GITLAB_PRIVATE_TOKEN (CI/CD > Environment Variables). This is necessary to raise the Merge Request on your behalf.
More informationclick here.
An example CI using this can be foundhere,
look for thecreate:merge-requestjob.Add the following to your.gitlab-ci.ymlfile:stages:-openopen_merge_request:image:registry.gitlab.com/gitlab-automation-toolkit/gitlab-auto-mrbefore_script:[]# We do not need any setup work, let's remove the global one (if any)stage:openscript:-gitlab_auto_mr -t master -c Draft -d ./.gitlab/merge_request/merge_request.md -r -s --use-issue-namePredefined VariablesPlease note some of the arguments can be filled in using environment variables defined during GitLab CI.
For more informationclick here <https://docs.gitlab.com/ee/ci/variables/predefined_variables.html>_.If--private-tokenis not set the script will look for the ENV variableGITLAB_PRIVATE_TOKENIf--source-branchis not set the script will look for the ENV variableCI_COMMIT_REF_NAMEIf--project-idis not set it will look for for the ENV variableCI_PROJECT_IDIf--gitlab-urlis not set it will look for for the ENV variableCI_PROJECT_URLIf--user-idis not set it will look for for the ENV variableGITLAB_USER_IDSetup Development Environmentgitclonegit@gitlab.com:gitlab-automation-toolkit/gitlab-auto-mr.gitcdgitlab-auto-mrpipinstalltoxmakeinstall-venvsource.venv/bin/activatemakeinstall-devChangelogYou can find thechangelog here.AppendixExtra features:AllsimonForked from:Tobias L. MaierScript and idea:Riccardo Padovani