GitLab is an open-source DevOps platform originally built as a Git-based source code management tool but has since expanded into many areas including CI/CD.
To upload a package to a Cloudsmith repository using a Gitlab CI/CD pipeline, you can either use the Cloudsmith CLI or the native package management tooling, such as
gem push or
cargo publish (where supported)
In either case, you will need to add your Cloudsmith API Key to your GitLab CI/CD environment
Retrieve your Cloudsmith API Key.
To use the Cloudsmith CLI with GitLab CI/CD Pipelines, you will need to add your Cloudsmith API Key to your GitLab repository as a CI/CD environment variable named
Please see the GitLab CI/CD environment variables documentation for further details.
If using native package management tooling to upload your package, you will need to add your Cloudsmith API Key to the credentials file or location that the native tools require. Please see the documentation for your specific package management tool for further details.
You can then use GitLab CI/CD file variables to securely store your Cloudsmith API Key and create the required credentials file from this file variable during a pipeline run.
To push a Ruby package via
gem push using GitLab CI/CD, you will need to add the following
- An environment variable, called
RUBYGEMS_HOST, containing the URL for your Cloudsmith repository to your GitLab CD/CD pipeline
variables: RUBYGEMS_HOST: "https://ruby.cloudsmith.io/OWNER/REPOSITORY"
- A file variable, called
CLOUDSMITH_API_KEY, to your repository CI/CD settings:
--- :rubygem_api_key: Token <YOUR_CLOUDSMITH_API_KEY>
- A push stage in your GitLab CI/CD pipeline
.gitlab-ci.ymlfile, which will create the required
~/.gem/credentialsfile, copy in the contents of the
CLOUDSMITH_API_KEYfile variable and then run the
gem pushcommand to upload your Ruby package to your Cloudsmith repository
push: stage: push script: - mkdir -p ~/.gem - mv $CLOUDSMITH_API_KEY ~/.gem/credentials && chmod 0600 ~/.gem/credentials - gem push <YOUR_PACKAGE_NAME>.gem
Updated over 1 year ago