You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/authentication/openid-connect.mdx
+19-48Lines changed: 19 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -184,69 +184,40 @@ pipelines:
184
184
185
185
#### CircleCI Example
186
186
187
+
Using the [Cloudsmith CircleCI orb](https://circleci.com/developer/orbs/orb/cloudsmith/cloudsmith), the `authenticate-with-oidc` command handles the token exchange automatically and exports the result as `CLOUDSMITH_API_KEY`:
If successful, this will give a JWT token to be used as an API key.
214
-
215
-
If unsuccessful, you will receive an error message that is intentionally quite generic. This is by design so that we do not leak any information (such as whether OIDC is configured, which claim failed, whether a service account is associated with the provider, etc.).
216
-
217
-
Additionally, as of version `1.0.6` of the Cloudsmith orb, you can use the `authenticate-with-oidc` command to perform this step automatically.
Ensure OIDC is enabled in your CircleCI project settings (Project Settings → Advanced → Enable OpenID Connect Tokens).
218
+
219
+
If successful, `CLOUDSMITH_API_KEY` will be set for all subsequent steps. If unsuccessful, you will receive an error message that is intentionally quite generic. This is by design so that we do not leak any information (such as whether OIDC is configured, which claim failed, whether a service account is associated with the provider, etc.).
220
+
250
221
#### GitHub Actions Example
251
222
252
223
```yaml
@@ -266,7 +237,7 @@ jobs:
266
237
uses: actions/checkout@v4
267
238
268
239
- name: Authenticate with Cloudsmith via OIDC
269
-
uses: cloudsmith-io/cloudsmith-cli-action@v1.0.3
240
+
uses: cloudsmith-io/cloudsmith-cli-action@v2
270
241
with:
271
242
oidc-namespace: 'your-oidc-workspace' # Replace with your Cloudsmith workspace
272
243
oidc-service-slug: 'your-service-account-slug' # Replace with the slug of your Cloudsmith service account
Copy file name to clipboardExpand all lines: src/content/integrations/integrating-with-circleci.mdx
+49-77Lines changed: 49 additions & 77 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,129 +37,101 @@ And then include the orb:
37
37
38
38
```yaml
39
39
orbs:
40
-
cloudsmith: cloudsmith/cloudsmith@1.0.6
40
+
cloudsmith: cloudsmith/cloudsmith@2.0.0
41
41
```
42
42
43
-
Note that you can check the [releases page on github](https://github.com/cloudsmith-io/orb/releases) for our orb, [or the orb page](https://circleci.com/developer/orbs/orb/cloudsmith/cloudsmith) on CircleCI itself to find the latest version to use.
43
+
Note that you can check the [releases page on GitHub](https://github.com/cloudsmith-io/orb/releases) for our orb, [or the orb page](https://circleci.com/developer/orbs/orb/cloudsmith/cloudsmith) on CircleCI itself to find the latest version to use.
44
44
45
-
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:
47
+
The recommended approach is to authenticate via OIDC, install the CLI, and invoke it directly in your run steps. This uses short-lived tokens and avoids storing long-lived API keys:
50
48
51
49
```yaml
52
-
jobs:
53
-
publish:
54
-
executor: circleci/python:3.7
55
-
steps:
56
-
- checkout
57
-
- run:
58
-
name: Build Python package
59
-
command: python setup.py sdist
50
+
version: 2.1
51
+
52
+
orbs:
53
+
cloudsmith: cloudsmith/cloudsmith@2.0.0
60
54
61
55
workflows:
62
-
cloudsmith_publish:
56
+
cloudsmith_oidc_publish:
63
57
jobs:
64
58
- publish
65
-
```
66
-
67
-
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:
68
59
69
-
```yaml
70
60
jobs:
71
61
publish:
72
-
executor: circleci/python:3.7
62
+
executor: cloudsmith/default
73
63
steps:
74
64
- checkout
75
-
- cloudsmith/ensure-api-key
65
+
- cloudsmith/authenticate-with-oidc:
66
+
organization: my-org
67
+
service-account: my-service-account
76
68
- cloudsmith/install-cli
77
69
- run:
78
-
name: Build Python package
79
-
command: python setup.py sdist
80
-
- cloudsmith/publish:
81
-
cloudsmith-repository: myorg/myrepo
82
-
package-path: dist/package-*.tar.gz
83
-
package-format: python
70
+
name: Build and publish Python package
71
+
command: |
72
+
pip install build
73
+
python -m build --wheel
74
+
cloudsmith push python my-org/my-repo dist/*.whl
84
75
```
85
76
86
-
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.
77
+
The `authenticate-with-oidc` command exchanges a CircleCI OIDC token for a short-lived Cloudsmith API token, exported as `CLOUDSMITH_API_KEY`. Ensure OIDC is enabled in your CircleCI project settings (Project Settings → Advanced → Enable OpenID Connect Tokens).
87
78
88
-
```
89
-
...
79
+
If you only need the API token and don't need to install the CLI, you can use `authenticate-with-oidc` on its own:
80
+
81
+
```yaml
90
82
jobs:
91
-
publish:
92
-
executor: circleci/python:3.7
83
+
authenticate:
84
+
executor: cloudsmith/default
93
85
steps:
94
86
- checkout
95
87
- cloudsmith/authenticate-with-oidc:
96
-
organization: <organizationslug>
97
-
service-account: <serviceaccountslug>
98
-
- cloudsmith/ensure-api-key
99
-
...
88
+
organization: my-org
89
+
service-account: my-service-account
90
+
- run:
91
+
name: Call Cloudsmith API
92
+
command: |
93
+
curl -H "X-Api-Key: $CLOUDSMITH_API_KEY" \
94
+
https://api.cloudsmith.io/user/self/
100
95
```
101
96
102
-
Putting this all together, we end up with a `.circleci/config.yaml` file which looks like so:
97
+
### API Key Authentication
98
+
99
+
If OIDC is not available in your environment, you can authenticate with a static API key. Add an environment variable named `CLOUDSMITH_API_KEY` in your CircleCI project settings:
Then use `ensure-api-key` to validate the key is set before running CLI commands:
103
104
104
105
```yaml
105
106
version: 2.1
106
107
107
108
orbs:
108
-
cloudsmith: cloudsmith/cloudsmith@1.0.4
109
-
110
-
jobs:
111
-
publish:
112
-
executor: circleci/python:3.7
113
-
steps:
114
-
- checkout
115
-
- cloudsmith/ensure-api-key
116
-
- cloudsmith/install-cli
117
-
- run:
118
-
name: Build Python package
119
-
command: python setup.py sdist
120
-
- cloudsmith/publish:
121
-
cloudsmith-repository: myorg/myrepo
122
-
package-path: dist/package-*.tar.gz
123
-
package-format: python
109
+
cloudsmith: cloudsmith/cloudsmith@2.0.0
124
110
125
111
workflows:
126
112
cloudsmith_publish:
127
113
jobs:
128
114
- publish
129
-
```
130
-
131
-
## Manual integration
132
-
133
-
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.
134
-
135
-
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:
The `cloudsmith/default` executor uses the `cimg/python` convenience image. If you need a different base image, you can specify your own executor and the orb commands will work in any environment that has the required dependencies (Python, curl, jq).
133
+
</Note>
134
+
163
135
## Support
164
136
165
137
As always, if you have any questions about integration or would like some general advice, please [contact support](https://cloudsmith.com/company/contact-us).
0 commit comments