Skip to main content

This tool is used to download a snippet from Gitlab to a local file.

It is primarily intended for use within a Gitlab CI/CD pipeline, but may be used as a standalone tool elsewhere. When used in a pipeline the –gl-url`, --proj_id and token are already defined by Gitlab.

Installation

From Pypi:

pip install gl-snippet

Usage

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.

Each snippet in Gitlab needs to be a single-file snippet (due to the limited way the gitlab-python snippet API works). A snipped may be a “global” or a project snippet. To access a “global” snippet from within a Gitlab pipeline supply --proj_id ""

Example from a .gitlab-ci.yml:

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

Example from desktop:

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

Release Notes

0.1.6.0

  • Build as “–universal”

0.1.5.0

  • Creates target directory if not already created

  • Default --proj_id to 0 for “global” snippets

Metadata

Release files for gl-snippet 0.1.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for gl-snippet 0.1.7.0
File Interpreter ABI Platform
gl_snippet-0.1.7.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Release files / gl_snippet-0.1.7.0-py2.py3-none-any.whl

Download URL gl_snippet-0.1.7.0-py2.py3-none-any.whl
Size 4.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
90ea068df1a5beeae10d1047d4ae4b0f9396408bd4805238421ba7cf2f3bcc42
BLAKE2b-256 checksum
How to use checksums
53fcd3a94f294c62af7bc912377bdc87e8c86438cc2ec0d2cef8904f74bbba8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

Release history Release notifications | RSS feed

This release

0.1.7.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page