CircleCI
How to integrate CircleCI with Cloudsmith
Cloudsmith provides first-class support for CircleCI with our official orb. Using the orb, users can easily integrate publishing to Cloudsmith with their existing CircleCI workflows.
Full reference documentation for the orb can be found on the CircleCI website. This documentation is automatically generated from the orb itself and so is guaranteed to always be up to date with the latest release of the orb.
Orb usage example
To use the orb you must first ensure you are using Circle version 2.1. At the top of your .circleci/config.yml
file you should add:
version: 2.1
And then include the orb:
orbs:
cloudsmith: cloudsmith/[email protected]
Note that you can check the releases page on github for our orb, or the orb page on CircleCI itself to find the latest version to use.
You'll need to configure authentication credentials for the orb if you're not planning to use OIDC to authenticate with. To do so, you can add an environment variable named CLOUDSMITH_API_KEY
within the CircleCI settings page for your project:
The orb (for now) requires that you have already built the package you wish to publish. Assuming you're publishing a Python library (though the same process applies to any package type), you'll want to run setup.py sdist
as a step in your job:
jobs:
publish:
executor: circleci/python:3.7
steps:
- checkout
- run:
name: Build Python package
command: python setup.py sdist
workflows:
cloudsmith_publish:
jobs:
- publish
Once built, we can use the orb to easily publish the package. The orb provides a number of commands to make this process simpler. We'll first ensure the Cloudsmith CLi is configured and installed, then after we've built the package, publish it:
jobs:
publish:
executor: circleci/python:3.7
steps:
- checkout
- cloudsmith/ensure-api-key
- cloudsmith/install-cli
- run:
name: Build Python package
command: python setup.py sdist
- cloudsmith/publish:
cloudsmith-repository: myorg/myrepo
package-path: dist/package-*.tar.gz
package-format: python
If using OIDC for authentication, ensure you're using at least version 1.0.6
of the Cloudsmith orb and add an extra step calling authenticate-with-oidc
e.g.
...
jobs:
publish:
executor: circleci/python:3.7
steps:
- checkout
- cloudsmith/authenticate-with-oidc:
organization: <organization slug>
service-account: <service account slug>
- cloudsmith/ensure-api-key
...
Putting this all together, we end up with a .circleci/config.yaml
file which looks like so:
version: 2.1
orbs:
cloudsmith: cloudsmith/[email protected]
jobs:
publish:
executor: circleci/python:3.7
steps:
- checkout
- cloudsmith/ensure-api-key
- cloudsmith/install-cli
- run:
name: Build Python package
command: python setup.py sdist
- cloudsmith/publish:
cloudsmith-repository: myorg/myrepo
package-path: dist/package-*.tar.gz
package-format: python
workflows:
cloudsmith_publish:
jobs:
- publish
Manual integration
Our official Orb provides simple integration for the majority of standard CI usecases, but we know that it won't fit every purpose. For additional flexibility users can mix and match commands provided by the orb and/or use the Cloudsmith CLI directly.
For example, to use the orb to install and configure the CLI, but then use the CLI directly to publish to Cloudsmith, your configuration might look like so:
version: 2.1
orbs:
cloudsmith: cloudsmith/[email protected]
jobs:
publish:
executor: circleci/python:3.7
steps:
- checkout
- cloudsmith/ensure-api-key
- cloudsmith/install-cli
- run:
name: Build Python package
command: python setup.py bdist_wheel
- run:
name: Publish Python package
command: cloudsmith push python myorg/myrepo dist/my-package-0.1.0.whl
workflows:
cloudsmith_publish:
jobs:
- publish
Support
As always, if you have any questions about integration or would like some general advice, please contact support.
Updated 5 months ago