Skip to main content

“获取片段到本地文件”

项目描述

该工具用于从 Gitlab 下载片段到本地文件。

它主要用于 Gitlab CI/CD 管道,但可以在其他地方用作独立工具。在管道中使用时,–gl-url`–proj_idtoken已经由 Gitlab 定义。

安装

来自皮皮:

pip install gl-snippet

用法

Usage: gl-snippet [OPTIONS] SNIP_ID TARGET

  Fetch a snippet contents from Gitlab.

  This is used to fetch the contents of a snippet and save it to a file.
  Note that the snippet must be a single-file snippet. Gitlab supports
  snippets with multiple files (but their python-gitlab API doesn't really
  handle multi-file snippets very well.)

  The parameters --gl-url, --proj_id and --token may be specified directly
  or as environment variables. These use the standard Gitlab CI/CD pipeline
  variables.

  A use-case for this is to store the contents for .pypirc or pip.conf in a
  snippet to fetch for a Gitlab pipeline step.

Options:
  --gl-url TEXT      URL to Gitlab server (CI_SERVER_URL)
  --proj_id INTEGER  Project ID (CI_PROJECT_ID)
  -t, --token TEXT   API access token (CI_JOB_TOKEN)
  --help             Show this message and exit.

Gitlab 中的每个片段都需要是一个单文件片段(由于 gitlab-python片段 API 的工作方式有限)。片段可能是“全局”或项目片段。从 Gitlab 管道供应中访问“全局”片段--proj_id ""

来自.gitlab-ci.yml 的示例

before_script:
  - pip install gl-snippet
  - gl-snippet 25 ~/.pypirc

桌面示例:

$ pip install gl-snippet
$ gl-snippet --gl-url https://gitlab.com --proj_id 529 --token <your_api_token> 25 ~/.pypirc

发行说明

0.1.6.0

  • 构建为“通用”

0.1.5.0

  • 如果尚未创建,则创建目标目录

  • 对于“全局”片段,默认--proj_id为 0

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

内置分布

gl_snippet-0.1.7.0-py2.py3-none-any.whl (4.6 kB 查看哈希)

已上传 py2 py3