Skip to main content

circleci Submodule

Constructs

Circleci

Circleci Class to manage .circleci/config.yml. Check projen's docs for more information.

https://circleci.com/docs/2.0/configuration-reference/

Initializers

import { circleci } from 'projen'

new circleci.Circleci(project: Project, options?: CircleCiProps)
NameTypeDescription
project
projen.ProjectNo description.
options
CircleCiProps
No description.

projectRequired
  • Type: projen.Project

optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
addOrb
Add a Circleci Orb to pipeline.
addWorkflow
add new workflow to existing pipeline.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

addOrb
public addOrb(name: string, orb: string): void

Add a Circleci Orb to pipeline.

Will throw error if the orb already exists

nameRequired
  • Type: string

orbRequired
  • Type: string

addWorkflow
public addWorkflow(workflow: Workflow): void

add new workflow to existing pipeline.

workflowRequired

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { circleci } from 'projen'

circleci.Circleci.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { circleci } from 'projen'

circleci.Circleci.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
file
projen.YamlFileThe yaml file for the Circleci pipeline.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

fileRequired
public readonly file: YamlFile;
  • Type: projen.YamlFile

The yaml file for the Circleci pipeline.


Structs

CircleCiProps

Options for class {@link Circleci}.

https://circleci.com/docs/2.0/configuration-reference/

Initializer

import { circleci } from 'projen'

const circleCiProps: circleci.CircleCiProps = { ... }

Properties

NameTypeDescription
jobs
Job[]
List of Jobs to create unique steps per pipeline, e.g. json jobs: [{ identifier: "compile", docker: { image: "golang:alpine" } steps: ["checkout", run: {command: "go build ."}] }] .
orbs
{[ key: string ]: string}Contains a map of CirclCi Orbs json orbs: { node: "circleci/node@5.0.1" slack: "circleci/slack@4.8.3" } .
setup
booleanThe setup field enables you to conditionally trigger configurations from outside the primary .circleci parent directory, update pipeline parameters, or generate customized configurations.
version
numberpipeline version.
workflows
Workflow[]
List of Workflows of pipeline, e.g. json workflows: { { identifier: "build", jobs: [{ identifier: "node/install", context: ["npm"], }] } } .

jobsOptional
public readonly jobs: Job[];

List of Jobs to create unique steps per pipeline, e.g. json jobs: [{ identifier: "compile", docker: { image: "golang:alpine" } steps: ["checkout", run: {command: "go build ."}] }] .

https://circleci.com/docs/2.0/configuration-reference/#jobs


orbsOptional
public readonly orbs: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Contains a map of CirclCi Orbs json orbs: { node: "circleci/node@5.0.1" slack: "circleci/slack@4.8.3" } .


setupOptional
public readonly setup: boolean;
  • Type: boolean

The setup field enables you to conditionally trigger configurations from outside the primary .circleci parent directory, update pipeline parameters, or generate customized configurations.

https://circleci.com/docs/2.0/configuration-reference/#setup


versionOptional
public readonly version: number;
  • Type: number
  • Default: 2.1

pipeline version.

https://circleci.com/docs/2.0/configuration-reference/#version


workflowsOptional
public readonly workflows: Workflow[];

List of Workflows of pipeline, e.g. json workflows: { { identifier: "build", jobs: [{ identifier: "node/install", context: ["npm"], }] } } .

https://circleci.com/docs/2.0/configuration-reference/#workflows


Docker

Options for docker executor.

https://circleci.com/docs/2.0/configuration-reference/#docker

Initializer

import { circleci } from 'projen'

const docker: circleci.Docker = { ... }

Properties

NameTypeDescription
image
stringThe name of a custom docker image to use.
auth
{[ key: string ]: string}Authentication for registries using standard docker login credentials.
awsAuth
{[ key: string ]: string}Authentication for AWS Elastic Container Registry (ECR).
command
string[]The command used as pid 1 (or args for entrypoint) when launching the container.
entrypoint
string[]The command used as executable when launching the container.
environment
{[ key: string ]: string | number | boolean}A map of environment variable names and values.
name
stringThe name the container is reachable by.
user
stringWhich user to run commands as within the Docker container.

imageRequired
public readonly image: string;
  • Type: string

The name of a custom docker image to use.


authOptional
public readonly auth: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Authentication for registries using standard docker login credentials.


awsAuthOptional
public readonly awsAuth: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Authentication for AWS Elastic Container Registry (ECR).


commandOptional
public readonly command: string[];
  • Type: string[]

The command used as pid 1 (or args for entrypoint) when launching the container.


entrypointOptional
public readonly entrypoint: string[];
  • Type: string[]

The command used as executable when launching the container.


environmentOptional
public readonly environment: {[ key: string ]: string | number | boolean};
  • Type: {[ key: string ]: string | number | boolean}

A map of environment variable names and values.


nameOptional
public readonly name: string;
  • Type: string

The name the container is reachable by.

By default, container services are accessible through localhost


userOptional
public readonly user: string;
  • Type: string

Which user to run commands as within the Docker container.


Filter

The branches key controls whether the current branch should have a schedule trigger created for it, where current branch is the branch containing the config.yml file with the trigger stanza. That is, a push on the main branch will only schedule a workflow for the main branch.

Branches can have the keys only and ignore which either map to a single string naming a branch. You may also use regular expressions to match against branches by enclosing them with /’s, or map to a list of such strings. Regular expressions must match the entire string.

Any branches that match only will run the job. Any branches that match ignore will not run the job. If neither only nor ignore are specified then all branches will run the job. If both only and ignore are specified the only is considered before ignore.

https://circleci.com/docs/2.0/configuration-reference/#filters

Initializer

import { circleci } from 'projen'

const filter: circleci.Filter = { ... }

Properties

NameTypeDescription
branches
FilterConfig
No description.
tags
FilterConfig
No description.

branchesOptional
public readonly branches: FilterConfig;

tagsOptional
public readonly tags: FilterConfig;

FilterConfig

set an inclusive or exclusive filter.

https://circleci.com/docs/2.0/configuration-reference/#filters

Initializer

import { circleci } from 'projen'

const filterConfig: circleci.FilterConfig = { ... }

Properties

NameTypeDescription
ignore
string[]Either a single branch specifier, or a list of branch specifiers.
only
string[]Either a single branch specifier, or a list of branch specifiers.

ignoreOptional
public readonly ignore: string[];
  • Type: string[]

Either a single branch specifier, or a list of branch specifiers.


onlyOptional
public readonly only: string[];
  • Type: string[]

Either a single branch specifier, or a list of branch specifiers.


Job

A Workflow is comprised of one or more uniquely named jobs.

Jobs are specified in the jobs map, see Sample 2.0 config.yml for two examples of a job map. The name of the job is the key in the map, and the value is a map describing the job. Each job consists of the job’s name as a key and a map as a value. A name should be case insensitive unique within a current jobs list.

https://circleci.com/docs/2.0/configuration-reference/#job_name

Initializer

import { circleci } from 'projen'

const job: circleci.Job = { ... }

Properties

NameTypeDescription
identifier
stringname of dynamic key *.
docker
Docker[]
No description.
environment
{[ key: string ]: string | number | boolean}A map of environment variable names and values.
machine
Machine
No description.
macos
Macos
No description.
parallelism
numberNumber of parallel instances of this job to run (default: 1).
parameters
{[ key: string ]: PipelineParameter}
Parameters for making a job explicitly configurable in a workflow.
resourceClass
string{@link ResourceClass}.
shell
stringShell to use for execution command in all steps.
steps
any[]no type support here, for syntax {@see https://circleci.com/docs/2.0/configuration-reference/#steps}.
workingDirectory
stringIn which directory to run the steps.

identifierRequired
public readonly identifier: string;
  • Type: string

name of dynamic key *.


dockerOptional
public readonly docker: Docker[];

environmentOptional
public readonly environment: {[ key: string ]: string | number | boolean};
  • Type: {[ key: string ]: string | number | boolean}

A map of environment variable names and values.


machineOptional
public readonly machine: Machine;

macosOptional
public readonly macos: Macos;

parallelismOptional
public readonly parallelism: number;
  • Type: number

Number of parallel instances of this job to run (default: 1).


parametersOptional
public readonly parameters: {[ key: string ]: PipelineParameter};

Parameters for making a job explicitly configurable in a workflow.


resourceClassOptional
public readonly resourceClass: string;
  • Type: string

{@link ResourceClass}.


shellOptional
public readonly shell: string;
  • Type: string

Shell to use for execution command in all steps.

Can be overridden by shell in each step


stepsOptional
public readonly steps: any[];
  • Type: any[]

no type support here, for syntax {@see https://circleci.com/docs/2.0/configuration-reference/#steps}.


workingDirectoryOptional
public readonly workingDirectory: string;
  • Type: string

In which directory to run the steps.

Will be interpreted as an absolute path. Default: ~/project


Machine

Initializer

import { circleci } from 'projen'

const machine: circleci.Machine = { ... }

Properties

NameTypeDescription
image
stringThe VM image to use.
dockerLayerCaching
stringenable docker layer caching.

imageRequired
public readonly image: string;
  • Type: string

The VM image to use.

https://circleci.com/docs/2.0/configuration-reference/#available-machine-images


dockerLayerCachingOptional
public readonly dockerLayerCaching: string;
  • Type: string

enable docker layer caching.

https://circleci.com/docs/2.0/configuration-reference/#available-machine-images


Macos

CircleCI supports running jobs on macOS, to allow you to build, test, and deploy apps for macOS, iOS, tvOS and watchOS.

To run a job in a macOS virtual machine, you must add the macos key to the top-level configuration for the job and specify the version of Xcode you would like to use.

https://circleci.com/docs/2.0/configuration-reference/#macos

Initializer

import { circleci } from 'projen'

const macos: circleci.Macos = { ... }

Properties

NameTypeDescription
xcode
stringThe version of Xcode that is installed on the virtual machine.

xcodeRequired
public readonly xcode: string;
  • Type: string

The version of Xcode that is installed on the virtual machine.


Matrix

The matrix stanza allows you to run a parameterized job multiple times with different arguments.

https://circleci.com/docs/2.0/configuration-reference/#matrix-requires-version-21

Initializer

import { circleci } from 'projen'

const matrix: circleci.Matrix = { ... }

Properties

NameTypeDescription
alias
stringAn alias for the matrix, usable from another job’s requires stanza.
parameters
{[ key: string ]: string[] | number[]}A map of parameter names to every value the job should be called with.

aliasOptional
public readonly alias: string;
  • Type: string

An alias for the matrix, usable from another job’s requires stanza.

Defaults to the name of the job being executed


parametersOptional
public readonly parameters: {[ key: string ]: string[] | number[]};
  • Type: {[ key: string ]: string[] | number[]}

A map of parameter names to every value the job should be called with.


PipelineParameter

Parameters are declared by name under a job, command, or executor.

https://circleci.com/docs/2.0/reusing-config#using-the-parameters-declaration

Initializer

import { circleci } from 'projen'

const pipelineParameter: circleci.PipelineParameter = { ... }

Properties

NameTypeDescription
type
PipelineParameterType
The parameter type, required.
default
string | number | booleanThe default value for the parameter.
description
stringUsed to generate documentation for your orb.

typeRequired
public readonly type: PipelineParameterType;

The parameter type, required.


defaultOptional
public readonly default: string | number | boolean;
  • Type: string | number | boolean

The default value for the parameter.

If not present, the parameter is implied to be required.


descriptionOptional
public readonly description: string;
  • Type: string

Used to generate documentation for your orb.


Run

Used for invoking all command-line programs, taking either a map of configuration values, or, when called in its short-form, a string that will be used as both the command and name.

Run commands are executed using non-login shells by default, so you must explicitly source any dotfiles as part of the command.

Not used because type incompatible types in steps array

https://circleci.com/docs/2.0/configuration-reference/#run

Initializer

import { circleci } from 'projen'

const run: circleci.Run = { ... }

Properties

NameTypeDescription
command
stringCommand to run via the shell.
background
stringWhether this step should run in the background (default: false).
environment
stringAdditional environmental variables, locally scoped to command.
name
stringTitle of the step to be shown in the CircleCI UI (default: full command).
noOutputTimeout
stringElapsed time the command can run without output such as “20m”, “1.25h”, “5s”. The default is 10 minutes.
shell
stringShell to use for execution command.
when
stringSpecify when to enable or disable the step.
workingDirectory
stringIn which directory to run this step.

commandRequired
public readonly command: string;
  • Type: string

Command to run via the shell.


backgroundOptional
public readonly background: string;
  • Type: string

Whether this step should run in the background (default: false).


environmentOptional
public readonly environment: string;
  • Type: string

Additional environmental variables, locally scoped to command.


nameOptional
public readonly name: string;
  • Type: string

Title of the step to be shown in the CircleCI UI (default: full command).


noOutputTimeoutOptional
public readonly noOutputTimeout: string;
  • Type: string

Elapsed time the command can run without output such as “20m”, “1.25h”, “5s”. The default is 10 minutes.


shellOptional
public readonly shell: string;
  • Type: string

Shell to use for execution command.


whenOptional
public readonly when: string;
  • Type: string

Specify when to enable or disable the step.


workingDirectoryOptional
public readonly workingDirectory: string;
  • Type: string

In which directory to run this step.

Will be interpreted relative to the working_directory of the job). (default: .)


Schedule

A workflow may have a schedule indicating it runs at a certain time.

https://circleci.com/docs/2.0/configuration-reference/#schedule

Initializer

import { circleci } from 'projen'

const schedule: circleci.Schedule = { ... }

Properties

NameTypeDescription
filters
Filter
No description.
cron
stringThe cron key is defined using POSIX crontab syntax.

filtersRequired
public readonly filters: Filter;

cronOptional
public readonly cron: string;
  • Type: string

The cron key is defined using POSIX crontab syntax.


StepRun

Execution steps for Job.

https://circleci.com/docs/2.0/configuration-reference/#steps

Initializer

import { circleci } from 'projen'

const stepRun: circleci.StepRun = { ... }

Properties

NameTypeDescription
run
Run
No description.

runOptional
public readonly run: Run;

Triggers

Specifies which triggers will cause this workflow to be executed.

Default behavior is to trigger the workflow when pushing to a branch.

https://circleci.com/docs/2.0/configuration-reference/#triggers

Initializer

import { circleci } from 'projen'

const triggers: circleci.Triggers = { ... }

Properties

NameTypeDescription
schedule
Schedule
No description.

scheduleOptional
public readonly schedule: Schedule;

Workflow

Used for orchestrating all jobs.

Each workflow consists of the workflow name as a key and a map as a value. A name should be unique within the current config.yml. The top-level keys for the Workflows configuration are version and jobs.

https://circleci.com/docs/2.0/configuration-reference/#workflows

Initializer

import { circleci } from 'projen'

const workflow: circleci.Workflow = { ... }

Properties

NameTypeDescription
identifier
stringname of dynamic key *.
jobs
WorkflowJob[]
No description.
triggers
Triggers[]
No description.
when
anywhen is too dynamic to be casted to interfaces.

identifierRequired
public readonly identifier: string;
  • Type: string

name of dynamic key *.


jobsOptional
public readonly jobs: WorkflowJob[];

triggersOptional
public readonly triggers: Triggers[];

whenOptional
public readonly when: any;
  • Type: any

when is too dynamic to be casted to interfaces.

Check Docu as reference

https://circleci.com/docs/2.0/configuration-reference/#logic-statement-examples


WorkflowJob

A Job is part of Workflow.

A Job can be created with {@link Job} or it can be provided by the orb

https://circleci.com/docs/2.0/configuration-reference/#jobs-in-workflow

Initializer

import { circleci } from 'projen'

const workflowJob: circleci.WorkflowJob = { ... }

Properties

NameTypeDescription
identifier
stringname of dynamic key *.
context
string[]The name of the context(s).
filters
Filter
Job Filters can have the key branches or tags.
matrix
Matrix
No description.
name
stringA replacement for the job name.
orbParameters
{[ key: string ]: string | number | boolean}Parameters passed to job when referencing a job from orb.
requires
string[]A list of jobs that must succeed for the job to start.
type
JobType
A job may have a type of approval indicating it must be manually approved before downstream jobs may proceed.

identifierRequired
public readonly identifier: string;
  • Type: string

name of dynamic key *.


contextOptional
public readonly context: string[];
  • Type: string[]

The name of the context(s).

The initial default name is org-global. Each context name must be unique.


filtersOptional
public readonly filters: Filter;

Job Filters can have the key branches or tags.


matrixOptional
public readonly matrix: Matrix;

nameOptional
public readonly name: string;
  • Type: string

A replacement for the job name.

Useful when calling a job multiple times


orbParametersOptional
public readonly orbParameters: {[ key: string ]: string | number | boolean};
  • Type: {[ key: string ]: string | number | boolean}

Parameters passed to job when referencing a job from orb.


requiresOptional
public readonly requires: string[];
  • Type: string[]

A list of jobs that must succeed for the job to start.


typeOptional
public readonly type: JobType;

A job may have a type of approval indicating it must be manually approved before downstream jobs may proceed.


Enums

JobType

A job may have a type of approval indicating it must be manually approved before downstream jobs may proceed.

https://circleci.com/docs/2.0/configuration-reference/#type

Members

NameDescription
APPROVAL
No description.

APPROVAL

JobWhen

Specify when to enable or disable the step.

https://circleci.com/docs/2.0/configuration-reference/#steps

Members

NameDescription
ALWAYS
No description.
ON_SUCCESS
No description.
ON_FAIL
No description.

ALWAYS

ON_SUCCESS

ON_FAIL

PipelineParameterType

Pipeline parameter types.

https://circleci.com/docs/2.0/reusing-config#parameter-syntax

Members

NameDescription
STRING
No description.
BOOLEAN
No description.
INTEGER
No description.
ENUM
No description.

STRING

BOOLEAN

INTEGER

ENUM

ResourceClass

The resource_class feature allows configuring CPU and RAM resources for each job.

Different resource classes are available for different executors, as described in the tables below.

https://circleci.com/docs/2.0/configuration-reference/#resourceclass

Members

NameDescription
SMALL
No description.
MEDIUM
No description.
MEDIUM_PLUS
No description.
LARGE_X
No description.
LARGE_2X
No description.
LARGE_2X_PLUS
No description.

SMALL

MEDIUM

MEDIUM_PLUS

LARGE_X

LARGE_2X

LARGE_2X_PLUS