Create an orb
On This Page
- Prerequisites
- Create your orb
- 1. Create a new repository
- 2. Initialize your orb
- 3. Choose the fully automated orb setup option
- GitHub App integration additional steps
- 4. Follow the prompts to set up your orb
- 5. Restrict who can trigger jobs for the orb
- 6. Push changes to GitHub
- 7. Complete the setup
- 8. Develop your orb
This tutorial guides you through creating a new orb using the orb development kit. The starting point is creating a new repository on GitHub.com.
Following this tutorial you will:
-
Create a GitHub repository for your orb.
-
Add template orb configuration, based on your requirements.
-
Set up a CI/CD pipeline for orb development, and put restrictions on who can contribute.
At the end of the tutorial you will be ready to configure your orb.
These steps are also outlined in the following video:
Prerequisites
-
A GitHub account connected to your CircleCI account. See the Sign up and try page for steps to get set up.
-
Set up the CircleCI CLI on your local machine with a personal access token. Ensure you are using the latest version of the CircleCI CLI. You must be using version
v0.1.17087
or later.circleci update circleci version
-
Register a namespace for your GitHub organization. Ensure the organization on GitHub is the owner for the CircleCI namespace for which you are developing your orb. This will be automatically configured correctly if you are using your own personal organization and namespace.
Create your orb
Once an orb is created it cannot be deleted. Orbs are SemVer compliant, and each published version is immutable. Publicly released orbs are potential dependencies for other projects. Therefore, allowing orb deletion would make users susceptible to unexpected loss of functionality. |
1. Create a new repository
Create a new, empty, GitHub repository. The name of your repository is not critical, but something similar to "myProject-orb" is recommended.
Ensure that the repository is completely empty. Uncheck any options such as "Add a README.md" or "Choose a license". |
![New GitHub repository](/docs/assets/img/docs/new_orb_repo_gh.png)
Once complete, you should see the generated git URL. Note it down, you will need it in step 4. You can select SSH or HTTPS, whichever you can authenticate with.
![Orb registry](/docs/assets/img/docs/github_new_quick_setup.png)
Do not pull down the orb repository at this point. This will be completed when you run orb init in the next step. Pulling the repository before this can cause issues. |
2. Initialize your orb
Open a terminal and initialize your new orb project using the orb init
CLI command as shown below. Use the --private
flag if required. The circleci orb init
command is called, followed by a path to create and initialize for your orb project. It is best practice to use the same name for this directory and the git repository.
Once an orb is initialized, it cannot be switched from public to private or vice versa. Ensure you add the --private flag if you intend to create a private orb. |
The --private flag is not currently supported on CircleCI server. Orbs created within a server installation will only be visible to authenticated users. |
3. Choose the fully automated orb setup option
Choose Yes, walk me through the process.
when prompted.
? Would you like to perform an automated setup of this orb?:
▸ Yes, walk me through the process.
No, I will handle everything myself.
When choosing the fully automated option, the orb template is downloaded and automatically modified with your customized settings. The project will be followed on CircleCI with an automated CI/CD pipeline included.
For more information on the included CI/CD pipeline, see the Orb publishing process page.
If you would like a convenient way to download the orb template you can opt to handle everything yourself. When choosing the manual option, see Manual orb authoring process for instructions on how to author and publish your orb. |
GitHub App integration additional steps
If your GitHub account is authorised with CircleCI using the GitHub App integration, you will need to follow some extra steps, as listed below. To find out if you authorized through the GitHub OAuth app or the CircleCI GitHub App, see the GitHub App integration page.
-
When prompted,
Are you using GitHub or Bitbucket or GitHub app (if GH App use circleci as the entry)?
, entercircleci
. -
When prompted,
Enter your circleci username or organization
, you will need to inspect the URL from the CircleCI web app and provide the org ID portion:-
Navigate to the CircleCI web app
-
The URL will be in the form:
https://app.circleci.com/pipelines/circleci/<org-ID-string>
. The last string is the org ID that you need.
-
-
At the end of the automated set up process you will receive an error:
Error: Could not follow project
. At this point you need to push your project up to GitHub, and set it up in a new CircleCI project. Steps for creating a new project can be found on the Create a project page. -
Once you have your orb pushed up to GitHub and your project set up, you will need to make a few manual updates:
-
In
config.yml
andtest-deploy-yml
, updatevcs_type: << pipeline.project.type >>
to bevcs_type: github
. -
In
src/@orb.yml
updatesource_url: <orb URL>
to besource_url: "https://github.com/<your-github-user-or-org-name>/<your-orb-repo-name>"
.
-
4. Follow the prompts to set up your orb
In the background, the orb init
command copies and customizes the orb template based on your inputs. There are detailed README.md
files within each directory that contain helpful information specific to the contents of each directory. You will be asked for the remote git repository URL that you obtained back in step 1.
The orb template contains a full CI/CD pipeline (described in orb publishing process), which automatically packs, tests, and publishes your orb.
In the setup process you will be asked if you would like to save your personal API Token into an orb-publishing
context. Saving this token is necessary for publishing development and production versions of your orb. If you have already made an orb in the past, you can skip this step, as the context will already exist.
5. Restrict who can trigger jobs for the orb
Use security groups to limit access to users that are allowed to trigger jobs. Only these users will have access to the private personal API token.
Contexts can be located by navigating to Organization Settings > Contexts in the web app. After creating your orb, you will have a new context called orb-publishing
. Click into orb-publishing
and add a Security Group.
6. Push changes to GitHub
During the setup process, the orb init
command prepares your automated orb development pipeline. The modified template code produced by the CLI must be pushed to the repository before the CLI can continue and automatically follow your project on CircleCI.
Run the following command from a separate terminal when prompted to do so, substituting the name of your default branch:
git push origin <default-branch>
Once complete, return to your terminal and confirm the changes have been pushed.
7. Complete the setup
Once the changes have been pushed, return to your terminal and continue the setup process. The CLI will now automatically follow the project on CircleCI, and attempt to trigger a pipeline to build and test your orb with sample code.
You will be provided with a link to the project building on CircleCI where you can view the full pipeline. You should also see the CLI has automatically migrated you into a new development branch, named alpha
. You can use any branch naming you would like, you do not need to exclusively develop on alpha
.
8. Develop your orb
From a non-default branch (you will be moved to the alpha
branch automatically at setup), begin modifying the sample orb code to fit your requirements. On each push, your orb will be automatically built and tested. More information on developing your orb can be found on the Orb authoring process page.
Be sure to view the .circleci/test-deploy
file to view how your orb components are being tested. You can modify your tests as you change your orb. Learn more about testing your orb on the Orb testing methodologies page.
When you are ready to deploy the first production version of your orb, head to the Orb publishing process page.