Python脚本,它将自动关闭GitLab上的问题。
gitlab-auto-close-issue的Python项目详细描述
gitlab自动关闭问题
这是一个简单的pythoncli脚本,允许您自动关闭GitLab上的问题。它的目的是 在CI/CD期间使用。但是,您可以选择使用它的任何你想。在
用法
首先,您需要创建一个个人访问令牌more information here。范围为api,因此它可以为您解决问题。在
pip install gitlab-auto-close-issue gitlab_auto_close_issue --help Usage: gitlab_auto_close_issue [OPTIONS] GitLab Auto Close Issue Options: --private-token TEXT Private GITLAB token, used to authenticate when calling the auto issue close API. [required] --project-id INTEGER The project ID on GitLab to create the auto close API for. [required] --gitlab-url TEXT The GitLab URL. [required] -i, --issue TEXT The Issue ID to close. [required] -r, --remove-label TEXT The labels to remove from (all) the issue(s) before closing it. --help Show this message and exit.^{pr2}$
GitLab CI
使用私有令牌在GitLab项目中设置一个秘密变量。将其命名为GITLAB_PRIVATE_TOKEN(CI/CD > Environment Variables)。 这是为您解决问题所必需的。 更多信息click here。 {$access通过这个参数^传递给脚本。 可以找到使用此方法的示例CI here, 查找close:issue作业。在
将以下内容添加到.gitlab-ci.yml文件中:
stages:-postclose:issue:image:registry.gitlab.com/gitlab-automation-toolkit/gitlab-auto-close-issuestage:postbefore_script:[]script:-gitlab_auto_close_issue --issue 1 --remove-label "Doing" --remove-label "To Do"
预定义变量
请注意,有些参数可以使用GitLab CI期间定义的环境变量填充。 有关详细信息,请单击此处<;https://docs.gitlab.com/ee/ci/variables/predefined_variables.html>_。在
- 如果未设置--private-token,则脚本将查找环境变量GITLAB_PRIVATE_TOKEN
- 如果未设置--source-branch,脚本将查找环境变量CI_COMMIT_REF_NAME
- 如果没有设置--project-id,它将查找ENV变量CI_PROJECT_ID
- 如果没有设置--gitlab-url,它将查找ENV变量CI_PROJECT_URL
- 如果未设置--user-id,它将查找环境变量GITLAB_USER_ID
设置开发环境
git clone git@gitlab.com:gitlab-automation-toolkit/gitlab-auto-close-issue.git
cd gitlab-auto-close-issue
pip install tox
make virtualenv
make install-dev
变更日志
你可以找到changelog here。在
- 项目
标签: