Gitlab CI中用于将文件(从生成)上载到当前项目版本(标记)的实用程序
gitlab-release的Python项目详细描述
此python实用程序用于上载特定版本 从gitlab ci构建到gitlab上的标记发布页面的文件。
这允许将具有任意结构的文件或(生成的)zip添加到 一个方便下载的版本,而不是那些 一定程度上被限制为总是压缩文件夹结构 直接从文件系统。
它可以在.gitlab-ci.yml阶段中使用,例如:
release: stage: release image: python3 script: - pip3 install gitlab-release - gitlab-release *.zip only: - tags
或者,如果您想将一堆文件打包到一个zip中,并将其上载
release: stage: release image: python3 script: - pip3 install gitlab-release - gitlab-release --zip "release-${CI_COMMIT_TAG}.zip" * only: - tags
或者,如果您只想将指向作业工件的链接添加到版本中:
release: stage: release image: python3 script: - pip3 install gitlab-release - gitlab-release --link-artifact *.zip artifacts: paths: # Must include files passed to gitlab_release - ./*.zip only: - tags
在任何标记的版本中,命令行中指定的文件将 在项目的标记选项卡上提供。
gitlab版本需要python 3。
设置所需的专用令牌
此工具要求您将PRIVATE_TOKEN的副本放在 项目的机密CI变量,使其可以发布文件 回到项目上来。
为此,在 https://gitlab.com/profile/personal_access_tokens然后用这个。(你 也可以使用您的个人令牌 https://gitlab.com/profile/account,但这是不推荐的)
确保在创建令牌时启用访问您的api。这个 令牌的名称只是为了让你记住它的用途,它不会 影响手术。
将其添加到名为PRIVATE_TOKEN的秘密变量中 在https://gitlab.com/<user>/<project>/settings/ci_cd>建造。
用法
usage: gitlab-release [-h] [--server SERVER] [--project_id PROJECT_ID] [--release_tag RELEASE_TAG] [--timeout TIMEOUT] [--ignore_cert] [--job-id JOB_ID] [--artifact-zip] [--zip ZIP] [--description DESCRIPTION] [--link-artifact] [--private-token PRIVATE_TOKEN] [files [files ...]]
positional arguments | |
---|---|
files | file names and/or globs of files to upload |
optional arguments | |
---|---|
–description DESCRIPTION | Release description to be put in front of the files |
–timeout TIMEOUT | Timeout for http requests |
–ignore_cert | Ignore ssl certificate failures |
–link-artifact | Link files as artifact from the current job instead of uploading |
–artifact-zip | Link artifacts zip from current job |
–job-id JOB_ID | Override the job number used for artifacts |
–zip ZIP | Add all provided files to provided zip name and upload that |
–server SERVER | url of gitlab server (default: $CI_PROJECT_URL) |
–project_id PROJECT_ID | Unique id of project, available in Project Settings/General (default: $CI_PROJECT_ID) |
–release_tag RELEASE_TAG | Tag to upload files against (default: $CI_BUILD_TAG) |
–private_token | login token with permissions to commit to repo |
-h, –help | show this help message and exit |