Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hmajid2301/gitlab-auto-mr
Python script which is used to create MRs on GitLab, mirrored from https://gitlab.com/hmajid2301/gitlab-automation-toolkit/gitlab-auto-mr
https://github.com/hmajid2301/gitlab-auto-mr
automation gitlab gitlab-ci python
Last synced: about 1 month ago
JSON representation
Python script which is used to create MRs on GitLab, mirrored from https://gitlab.com/hmajid2301/gitlab-automation-toolkit/gitlab-auto-mr
- Host: GitHub
- URL: https://github.com/hmajid2301/gitlab-auto-mr
- Owner: hmajid2301
- License: apache-2.0
- Created: 2019-03-16T19:38:02.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T04:52:35.000Z (about 2 years ago)
- Last Synced: 2023-03-01T13:55:38.167Z (almost 2 years ago)
- Topics: automation, gitlab, gitlab-ci, python
- Language: Python
- Homepage:
- Size: 88.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
.. image:: https://gitlab.com/gitlab-automation-toolkit/gitlab-auto-mr/badges/master/pipeline.svg
:target: https://gitlab.com/gitlab-automation-toolkit/gitlab-auto-mr
:alt: Pipeline Status.. image:: https://gitlab.com/gitlab-automation-toolkit/gitlab-auto-mr/badges/master/coverage.svg
:target: https://gitlab.com/gitlab-automation-toolkit/gitlab-auto-mr
:alt: Coverage.. image:: https://img.shields.io/pypi/l/gitlab-auto-mr.svg
:target: https://pypi.org/project/gitlab-auto-mr/
:alt: PyPI Project License.. image:: https://img.shields.io/pypi/v/gitlab-auto-mr.svg
:target: https://pypi.org/project/gitlab-auto-mr/
:alt: PyPI Project VersionGitLab Auto MR
==============This 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 of `Riccardo Padovani `_,
which he introduced with his blog post
`How to automatically create new MR on Gitlab with Gitlab CI `_.Usage
-----First you need to create a personal access token,
`more information here `_.
With the scope ``api``, so it can create the MR using your API. This access token is passed
to the script with the ``--private-token`` argument... code-block:: bash
pip install gitlab-auto-mr
gitlab_auto_mr --helpUsage: gitlab_auto_mr [OPTIONS]
Gitlab Auto MR Tool.
Options:
--private-token TEXT Private GITLAB token, used to authenticate when
calling the MR API. [required]
--source-branch TEXT The source branch to merge into. [required]
--project-id INTEGER The project ID on GitLab to create the MR for.
[required]
--gitlab-url TEXT The gitlab URL i.e. gitlab.com.
[required]
--user-id INTEGER The GitLab user ID to assign the created MR to.
[required]
-t, --target-branch TEXT The target branch to merge onto.
-c, --commit-prefix TEXT Prefix for the MR title i.e. WIP.
-r, --remove-branch Set to True if you want the source branch to be
removed after MR.
-s, --squash-commits Set to True if you want commits to be squashed.
-d, --description TEXT Path to file to use as the description for the MR.
--use-issue-name If set to True will use information from issue in
branch name, must be in the form #issue-number,
i.e feature/#6.
--allow-collaboration If set to True allow, commits from members who can
merge to the target branch.
--help Show this message and exit... code-block:: bash
gitlab_auto_mr --private-token $(private_token) --source-branch feature/test --project-id 5 \
--project-url https://gitlab.com/stegappasaurus/stegappasaurus-app --user-id 5GitLab CI
*********``GITLAB_PRIVATE_TOKEN`` Set 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 information `click here `_.
An example CI using this can be found
`here `_,
look for the ``create:merge-request`` job.Add the following to your ``.gitlab-ci.yml`` file:
.. code-block:: yaml
stages:
- openopen_merge_request:
image: registry.gitlab.com/gitlab-automation-toolkit/gitlab-auto-mr
before_script: [] # We do not need any setup work, let's remove the global one (if any)
stage: open
script:
- gitlab_auto_mr -t master -c WIP -d ./.gitlab/merge_request/merge_request.md -r -s --use-issue-namePredefined Variables
^^^^^^^^^^^^^^^^^^^^Please note some of the arguments can be filled in using environment variables defined during GitLab CI.
For more information `click here _`.* If ``--private-token`` is not set the script will look for the ENV variable ``GITLAB_PRIVATE_TOKEN``
* If ``--source-branch`` is not set the script will look for the ENV variable ``CI_COMMIT_REF_NAME``
* If ``--project-id`` is not set it will look for for the ENV variable ``CI_PROJECT_ID``
* If ``--gitlab-url`` is not set it will look for for the ENV variable ``CI_PROJECT_URL``
* If ``--user-id`` is not set it will look for for the ENV variable ``GITLAB_USER_ID``Setup Development Environment
=============================.. code-block:: bash
git clone [email protected]:gitlab-automation-toolkit/gitlab-auto-mr.git
cd gitlab-auto-mr
pip install tox
make install-venv
source .venv/bin/activate
make install-devChangelog
=========You can find the `changelog here `_.
Appendix
========- Extra features: `Allsimon `_
- Forked from: `Tobias L. Maier `_
- Script and idea: `Riccardo Padovani `_