Integrations
Integrating Jenkins
How to integrate Jenkins with Cloudsmith
Contextual Documentation
These instructions are generic examples. Cloudsmith provides contextual setup details for Jenkins, with copy and paste snippets (with your namespace/repo pre-configured) in the documentation within a repository.
API Key Configuration
If you haven't already done so you'll need to expose your Cloudsmith API Key within Jenkins. We recommend using the credentials plugin then injecting the CLOUDSMITH_API_KEY environment variable into your build jobs.
Alternatively, you can authenticate without a stored API key by using OpenID Connect (OIDC). Set the CLOUDSMITH_OIDC_TOKEN, CLOUDSMITH_ORG, and CLOUDSMITH_SERVICE_SLUG environment variables and the CLI automatically exchanges the OIDC token for a short-lived Cloudsmith token. See OpenID Connect for provider setup.
Examples
In the following examples:
| Identifier | Description |
|---|---|
| WORKSPACE | Your Cloudsmith Workspace slug |
| REPOSITORY | Your Cloudsmith Repository identifier (also called "slug") |
| FORMAT | The format of the package, i.e "deb", "maven", "npm" etc |
| PACKAGE_FILE | The filename of the package |
Build Steps Example
Add the following as a build step to perform the push to Cloudsmith:
# Jenkins Build Steps using CLI
set -eu
install_output="$(curl -fsSL https://install.cloudsmith.com/raw/versions/latest/cli.sh | sh -s -- --version 1.20.1)"
bin_dir="$(printf '%s\n' "$install_output" | sed -n 's/^bin_dir=//p')"
export PATH="$bin_dir:$PATH"
cloudsmith push FORMAT WORKSPACE/REPOSITORY PACKAGE_FILEThe install script downloads the standalone Cloudsmith CLI binary and prints the installation result as key=value lines; the commands above parse bin_dir from that output and add it to PATH. No Python or other runtime is required on the build agent. These examples are for Linux agents and require curl (or GNU wget), tar, and gzip; Windows agents use the install.ps1 script instead.
Pipelines Example
Add the following as a build stage to perform the push to Cloudsmith:
stage "Deploy"
sh '''
set -eu
install_output="$(curl -fsSL https://install.cloudsmith.com/raw/versions/latest/cli.sh | sh -s -- --version 1.20.1)"
bin_dir="$(printf '%s\n' "$install_output" | sed -n 's/^bin_dir=//p')"
export PATH="$bin_dir:$PATH"
cloudsmith push FORMAT WORKSPACE/REPOSITORY PACKAGE_FILE
'''Note
The push command will vary with the package format, an example of the push command for a debian package would look like:
bashcloudsmith push deb my-org/my-repo/ubuntu/xenial foo-1.0.debPlease see the Cloudsmith CLI for full details of the push command for other formats and additional help.