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
{{ message }}
This repository was archived by the owner on Apr 8, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: jekyll/_cci2/creating-orbs.md
+40-79Lines changed: 40 additions & 79 deletions
Original file line number
Diff line number
Diff line change
@@ -7,42 +7,49 @@ categories: [getting-started]
7
7
order: 1
8
8
---
9
9
10
-
Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects.
10
+
Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be [used across multiple projects]({{ site.baseurl }}/2.0/using-orbs/).
11
11
12
12
[Orbs]({{ site.baseurl }}/2.0/orb-intro/) are made available for use in a configuration through the `orbs` key in the top level of your 2.1 [.circleci/config.yml]({{ site.baseurl }}/2.0/configuration-reference/) file.
13
13
14
-
This document describes how you can:
14
+
## Getting Started
15
15
16
-
* Use an existing orb in your configuration
17
-
* Import an orb
18
-
* Create an inline orb in your `config.yml` file
19
-
* Create, validate, and publish an orb in the [CircleCI Orbs Registry](https://circleci.com/orbs/registry/)
16
+
The following animation shows the basics of creating and publishing an orb using an example:
CircleCI has made available a number of certified and 3rd-Party orbs that you may use in your configuration to reduce the time needed to get up and running using orbs in your configuration.
20
+
The animation shows snippets to give you an overview of the following steps for creating an orb:
24
21
25
-
By using CircleCI certified orbs, or 3rd-party orbs developed by CircleCI partners, you can be confident that these orbs have been developed and tested to ensure they work with the CircleCI platform.
22
+
1. Defining a reusable job named `orb-doc-generation` and checking the 2.1 config is well-formed with `circleci-config-validate .circleci/config.yml`.
23
+
2. Running `circleci config process .circleci/config.yml` to process the config.
24
+
3. Committing the change and checking that the build succeeds in the CircleCI app.
25
+
4. Enabling orbs use under Settings > Security in the CircleCI app.
26
+
5. Running `circleci namespace create ndintenfass` to create a namespace in which to publish to the [CircleCI Orb Registry](https://circleci.com/orbs/registry/).
27
+
6. Creating and committing an `orb.yml` file in a `.circleci/orbs/orb-utils` directory of the project repo with the content of a reusable executor and the `orb-doc-generation` job.
28
+
7. Running `circleci orb create ndintenfass orb-utils` to create the orb in the namespace.
29
+
8. Running `circleci orb publish dev .circleci/orbs/orb-utils/@orb.yml ndintenfass orb-utils test` to publish the dev:test orb.
30
+
9. Replacing the inline executor and job definitions in the `.circleci/config.yml` with the reference to the published `ndintenfass/orb-utils@dev:test` orb.
31
+
10. Running `circleci-config-validate .circleci/config.yml` to validate it is well-formed.
32
+
11. Committing the change and checking that the build succeeds when using the imported orb. The processed config appears on the Configuration tab of the CircleCI Jobs page.
26
33
27
-
### Certified Orbs
34
+
**Note:** Running `circleci setup`, providing a personal API token from the CircleCI app project settings page, and enabling [Build Processing]({{ site.baseurl }}/2.0/build-processing/) for your project are prerequisites for creating orbs.
28
35
29
-
Certified orbs are those that CircleCI has built or has reviewed and approved as part of the features of the CircleCI platform. Any project may use certified orbs in configuration version 2.1 and higher.
36
+
Give it a try! If you have any trouble, check out the additional details and tips below or the [Orbs FAQ]({{ site.baseurl }}/2.0/orbs-faq/).
30
37
31
-
### 3rd-Party Orbs
38
+
##Overview
32
39
33
-
3rd-party orbs are those published by CircleCI customers and other members of our community. For you to publish orbs or for your projects to use 3rd-party orbs, your organization must opt-in under Security within the Settings tab under the Orb Security Settings where an organization administrator must agree to the terms for using 3rd-party software.
40
+
This following sections of this document describe in more detail:
34
41
35
-
**Note:** The Security setting required for publishing or using 3rd-party orbs may only be toggled by organization administrators.
42
+
* Versioning and Designing orbs
43
+
* Creating an inline orb in your `config.yml` file with templates
44
+
* Creating, validating, and publishing an orb in the [CircleCI Orbs Registry](https://circleci.com/orbs/registry/)
36
45
37
-
### Orb Reference Format
46
+
Certified orbs are those that CircleCI has built or has reviewed and approved as part of the features of the CircleCI platform. Any project may use certified orbs in configuration version 2.1 and higher.
38
47
39
-
Orb references have the following format:
48
+
3rd-party orbs are those published by CircleCI customers and other members of our community. For you to publish orbs or for your projects to use 3rd-party orbs, your organization must opt-in under Security within the Settings tab under the Orb Security Settings where an organization administrator must agree to the terms for using 3rd-party software.
40
49
41
-
```
42
-
[namespace]/[orb]@[version]
43
-
```
50
+
**Note:** The Security setting required for publishing or using 3rd-party orbs may only be toggled by organization administrators.
44
51
45
-
####Semantic Versioning in Orbs
52
+
## Semantic Versioning in Orbs
46
53
47
54
Orbs are published with the standard 3-number semantic versioning system:
48
55
@@ -61,26 +68,15 @@ Examples of orb version declarations and their meaning:
61
68
3.```circleci/python@2.4``` - use the latest version of version 2.4.x of the Python orb.
62
69
4.```circleci/python@3.1.4``` - use exactly version 3.1.4 of the Python orb.
63
70
64
-
####Using Development Versions
71
+
### Using Development Versions
65
72
66
73
While all production orbs must be published securely by organization administrators, development orbs provide non-administrator members of the team with a way to publish orbs. Unlike production orbs, dev orbs are also mutable, so they are ideal for rapid iteration of an idea.
67
74
68
75
A development version must be referenced by its complete, fully-qualified name, such as: ```mynamespace/myorb@dev:mybranch.```; whereas production orbs allow wildcard semantic version references. Note that there are no shorthand conveniences for development versions.
69
76
70
77
**Note:** Dev versions are mutable and expire: their contents can change, and they are subject to deletion after 90 days; therefore, it is strongly recommended you do not rely on a development versions in any production software, and use them only while actively developing your orb. It is possible for admin members of a team to publish a semantic version of an orb based off of a dev orb instead of copy-pasting some config from another teammate.
71
78
72
-
73
-
## Importing an Orb
74
-
75
-
Importing a set of existing orbs is a simple process that only requires you to provide the following instruction in your configuration. In the example below, you can see how to import a CircleCI Slack and Heroku orb:
76
-
77
-
```
78
-
orbs:
79
-
slack: circleci/slack@0.1.0
80
-
heroku: circleci/heroku@volatile
81
-
```
82
-
83
-
### Designing Orbs
79
+
## Designing Orbs
84
80
85
81
When designing your own orbs, make sure your orbs meet the following requirements:
86
82
@@ -133,7 +129,7 @@ workflows:
133
129
In the example above, note that the contents of ```my-orb``` are resolved as an inline orb because the contents of ```my-orb``` are a map; whereas the contents of ```codecov``` are a scalar value, and thus assumed to be an orb URI.
134
130
135
131
136
-
### Example Template
132
+
### Example Inline Template
137
133
138
134
When you want to author an orb, you may wish to use this example template to quickly and easily create a new orb with all of the required components. This example includes each of the three top-level concepts of orbs. While any orb can be equally expressed as an inline orb definition, it will generally be simpler to iterate on an inline orb and use ```circleci config process .circleci/config.yml``` to check whether your orb usage matches your expectation.
139
135
@@ -193,49 +189,35 @@ Orbs may be authored inline in your config.yml file or authored separately and t
193
189
194
190
Before publishing an orb, you will need to first opt-in to the new Code Sharing Terms of Service and turn on orb publishing for your organization.
195
191
196
-
197
192
**Note:** Only an organization administrator can opt-in to the Code Sharing Terms of Service. The organization admin will need to navigate to the organization Settings tab and complete the form on the Security page.
198
193
199
-
200
-
### Orb Publishing Concepts
201
-
202
-
The sections below describe important concepts that you should understand before publishing an orb.
203
-
204
-
#### Orb Registry
205
-
206
-
CircleCI has a single orb registry. The registry on `circleci.com` serves as the master source for all certified namespaces and orbs. This master source is the only orb registry available to users of `circleci.com`.
207
-
208
-
<asideclass="notice">
209
-
Orbs are not yet supported for CircleCI installed on your private servers or cloud.
210
-
</aside>
211
-
212
-
#### Namespaces
194
+
### Namespaces
213
195
214
196
Namespaces are used to organize a set of orbs. Each namespace has a unique and immutable name within the registry, and each orb in a namespace has a unique name. For example, the `circleci/rails` orb may coexist in the registry with an orb called ```hannah/rails``` because they are in separate namespaces.
215
197
216
198
Namespaces are owned by organizations. Only organization administrators can create namespaces.
217
199
218
200
Organizations are, by default, limited to claiming only one namespace. This policy is designed to limit name-squatting and namespace noise. If you require more than one namespace please contact your account team at CircleCI.
219
201
220
-
####Development and Production Orbs
202
+
### Development and Production Orbs
221
203
222
204
Orb versions may be added to the registry either as development versions or production versions. Production versions are always a semantic version like 1.5.3; whereas development versions can be tagged with a string and are always prefixed with `dev:` for example `dev:myfirstorb`.
223
205
224
-
#####Development and Production Orb Security Profiles
206
+
### Development and Production Orb Security Profiles
225
207
226
208
* Only organization administrators can publish production orbs.
227
209
228
210
* Any member of an organization can publish dev orbs in namespaces.
229
211
230
212
* Organization administrators can promote any dev orb to be a semantically versioned production orb.
231
213
232
-
#####Development and Production Orb Retention and Mutability Characteristics
214
+
### Development and Production Orb Retention and Mutability Characteristics
233
215
234
216
* Dev orbs are mutable and expire. Anyone can overwrite any development orb who is a member of the organization that owns the namespace in which that orb is published.
235
217
236
218
* Production orbs are immutable and long-lived. Once you publish a production orb at a given semantic version you may not change the content of that orb at that version. To change the content of a production orb you must publish a new version with a unique version number. It is best practice to use the ```orb publish increment``` and/or the ```orb publish promote``` commands in the ```circleci``` CLI when publishing orbs to production.
237
219
238
-
#####Development and Production Orbs Versioning Semantics
220
+
### Development and Production Orbs Versioning Semantics
239
221
240
222
Development orbs are tagged with the format ```dev:<< your-string >>```. Production orbs are always published using the semantic versioning ("semver") scheme.
241
223
@@ -269,6 +251,7 @@ While not strictly enforced, it is best practice when versioning your production
269
251
* MINOR: when you add functionality in a backwards-compatible manner
270
252
* PATCH: when you make backwards-compatible bug fixes
271
253
254
+
272
255
#### Using Orbs Within Your Orb and Register-Time Resolution
273
256
274
257
You may use an ```orbs``` stanza inside an orb.
@@ -279,14 +262,13 @@ For example, orb ```foo/bar``` is published at version ```1.2.3``` with an ```or
279
262
280
263
If ```biz/baz``` is updated to ```3.0.0```, anyone using ```foo/bar@1.2.3``` will not see the change in ```biz/baz@3.0.0``` until ```foo/bar``` is published at a higher
8000
version than `1.2.3`.
281
264
282
-
283
-
#### Deleting Production Orbs
265
+
### Deleting Production Orbs
284
266
285
267
In general, CircleCI prefers to never delete production orbs that were published as world-readable because it harms the reliability of the orb registry as a source of configuration and the trust of all orb users.
286
268
287
269
If the case arises where you need to delete an orb for emergency reasons, please contact CircleCI (**Note:** If you are deleting because of a security concern, you must practice responsible disclosure using the [CircleCI Security](https://circleci.com/security/) web page.
288
270
289
-
####Using the CLI to Create and Publish Orbs
271
+
## Using the CLI to Create and Publish Orbs
290
272
291
273
The ```circleci``` CLI has several commands for managing your orb publishing pipeline. The simplest way to learn the CLI is to install it and run ```circleci help```. Refer to [Using the CircleCI CLI]( {{ site.baseurl }}/2.0/local-cli/#configuring-the-cli) for details. Listed below are some of the most pertinent commands for publishing orbs:
292
274
@@ -329,15 +311,14 @@ To publish an orb, follow the steps listed below as an org Admin.
329
311
7. Your orb is now published in an immutable form as a production version and can be used safely in builds. You can view the source of your orb by using:
330
312
`circleci orb source sandbox/hello-world@0.0.1`
331
313
332
-
333
314
## Creating a CircleCI Orb
334
315
335
316
This section describes each step of the orb creation and publishing process so you will have a deep understanding of how to write and publish your own orb. These examples enables you to follow the process step-by-step to ensure you write an orb that both adheres to CircleCI requirements while also meeting your own needs.
336
317
337
318
The following sections describe each step in the orb authoring and publishing process:
338
319
339
320
1. Meet initial CircleCI prerequisites
340
-
2.Import an existing orb or author
F428
your own orb
321
+
2.Author your own orb
341
322
3. Validate and publish your orb
342
323
343
324
## Meet Initial CircleCI Prerequisites
@@ -436,27 +417,7 @@ Config file at .circleci/config.yml is valid
436
417
437
418
After you have installed the CircleCI CLI tool, you will then need to set the version property to version 2.1. This is a very simple process, requiring you only to set the value of the top-level 'version' key in your configuration file. This will enable all 2.1 features and allow you to begin working with orbs in your environment.
438
419
439
-
## Import an Existing Orb or Author Your Own Orb
440
-
441
-
After you have met all of the prerequisites for working with orbs, you may now begin either working with an existing orb (via the import feature) or authoring your own orb. Because CircleCI has provided 20 certified and tested orbs, along with several 3rd-party orbs authored by CircleCI partners, it is best practice to first evaluate whether any of these existing orbs will help you in your configuration workflow.
442
-
443
-
### Importing an Existing Orb
444
-
445
-
If you wish to import an existing orb, it would be similar to the example shown below.
446
-
447
-
```
448
-
orbs:
449
-
slack: circleci/slack@0.1.0
450
-
heroku: circleci/heroku@1.0.0
451
-
```
452
-
453
-
In the above example, two orbs would be made available to you (slack & heroku), one for each key in the map.
454
-
455
-
Because the values of the above keys under `orbs` are all scalar values they are assumed to be imports based on the orb ref format of `${NAMESPACE}/${ORB_NAME}@${VERSION}`
456
-
457
-
### Authoring Your Own Orb
458
-
459
-
If you find that there are no existing orbs that meet your needs, you may wish to author your own orb to meet your specific environment or configuration requirements. Although this is more time-consuming than using the import feature, authoring your own orb enables you to create an orb that is specific to your organization.
420
+
### Authoring Your Orb
460
421
461
422
For examples of orb source, please refer to the [Public CircleCI Repo](https://github.com/CircleCI-Public/), where you will find source code for several certified orbs.
0 commit comments