CircleCI Config SDK
Create and manage your CircleCI configuration files with JavaScript and
TypeScript.
Table of Contents
Getting Started
Installation
Using npm:
$ npm i @circleci/circleci-config-sdk
Using yarn:
$ yarn add @circleci/circleci-config-sdk
Usage
In Node.js:
import CircleCI from '@circleci/circleci-config-sdk';
In Browser:
const CircleCI = require('@circleci/circleci-config-sdk');
Example
Generate a CircleCI config using TypeScript/Javascript, properly typed for full
IntelliSense support.
const CircleCI = require('@circleci/circleci-config-sdk');
const myConfig = new CircleCI.Config();
const myWorkflow = new CircleCI.Workflow('myWorkflow');
myConfig.addWorkflow(myWorkflow);
const nodeExecutor = new CircleCI.executors.DockerExecutor('cimg/node:lts');
const nodeTestJob = new CircleCI.Job('node-test', nodeExecutor);
myConfig.addJob(nodeTestJob);
nodeTestJob
.addStep(new CircleCI.commands.Checkout())
.addStep(
new CircleCI.commands.Run({
command: 'npm install',
name: 'NPM Install',
}),
)
.addStep(
new CircleCI.commands.Run({
command: 'npm run test',
name: 'Run tests',
}),
);
myWorkflow.addJob(nodeTestJob);
const MyYamlConfig = myConfig.stringify();
MyYamlConfig
will hold the following string (A valid CircleCI Config).
version: 2.1
setup: false
jobs:
node-test:
docker:
- image: cimg/node:lts
resource_class: medium
steps:
- checkout: {}
- run:
command: npm install
name: NPM Install
- run:
command: npm run test
name: Run tests
workflows:
myWorkflow:
jobs:
- node-test: {}
Getting Help
This open-source project utilized GitHub issues and project boards to manage
requests and support.
If you can not find an answer to your question in an existing
issue,
you may open a new issue with the appropriate template. Issues are the best way
for the CircleCI team and the open-source community to track and interact with
your questions.
Resources
Consider checking the following common resources before opening a new issue.
Contributing
This repository welcomes community contributions! See our
CONTRIBUTING.md
for guidance on configuring your development environment and how to submit
quality pull requests.
Related