build
Submodule
Constructs
BuildWorkflow
Initializers
import { build } from 'projen'
new build.BuildWorkflow(project: Project, options: BuildWorkflowOptions)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Required
- Type: BuildWorkflowOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| Adds another job to the build workflow which is executed after the build job succeeded. |
| Run a sequence of commands as a job within the build workflow which is executed after the build job succeeded. |
| Run a task as a job within the build workflow which is executed after the build job succeeded. |
| Adds steps that are executed after the build. |
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.
addPostBuildJob
public addPostBuildJob(id: string, job: Job): void
Adds another job to the build workflow which is executed after the build job succeeded.
Jobs are executed only if the build did NOT self mutate. If the build self-mutate, the branch will either be updated or the build will fail (in forks), so there is no point in executing the post-build job.
id
Required
- Type: string
The id of the new job.
job
Required
- Type: projen.github.workflows.Job
The job specification.
addPostBuildJobCommands
public addPostBuildJobCommands(id: string, commands: string[], options?: AddPostBuildJobCommandsOptions): void
Run a sequence of commands as a job within the build workflow which is executed after the build job succeeded.
Jobs are executed only if the build did NOT self mutate. If the build self-mutate, the branch will either be updated or the build will fail (in forks), so there is no point in executing the post-build job.
id
Required
- Type: string
commands
Required
- Type: string[]
options
Optional
Specify tools and other options.
addPostBuildJobTask
public addPostBuildJobTask(task: Task, options?: AddPostBuildJobTaskOptions): void
Run a task as a job within the build workflow which is executed after the build job succeeded.
The job will have access to build artifacts and will install project dependencies in order to be able to run any commands used in the tasks.
Jobs are executed only if the build did NOT self mutate. If the build self-mutate, the branch will either be updated or the build will fail (in forks), so there is no point in executing the post-build job.
task
Required
- Type: projen.Task
options
Optional
Specify tools and other options.
addPostBuildSteps
public addPostBuildSteps(steps: ...JobStep[]): void
Adds steps that are executed after the build.
steps
Required
- Type: ...projen.github.workflows.JobStep[]
The job steps.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
isConstruct
import { build } from 'projen'
build.BuildWorkflow.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.
x
Required
- Type: any
Any object.
isComponent
import { build } from 'projen'
build.BuildWorkflow.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| string[] | Returns a list of job IDs that are part of the build. |
| string | Name of generated github workflow. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
buildJobIds
Required
public readonly buildJobIds: string[];
- Type: string[]
Returns a list of job IDs that are part of the build.
name
Required
public readonly name: string;
- Type: string
Name of generated github workflow.
Structs
AddPostBuildJobCommandsOptions
Options for BuildWorkflow.addPostBuildJobCommands
.
Initializer
import { build } from 'projen'
const addPostBuildJobCommandsOptions: build.AddPostBuildJobCommandsOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| boolean | Check out the repository at the pull request branch before commands are run. |
| boolean | Install project dependencies before running commands. checkoutRepo must also be set to true. |
| string[] | Github Runner selection labels. |
| projen.GroupRunnerOptions | Github Runner Group selection options. |
| projen.github.workflows.Tools | Tools that should be installed before the commands are run. |
checkoutRepo
Optional
public readonly checkoutRepo: boolean;
- Type: boolean
- Default: false
Check out the repository at the pull request branch before commands are run.
installDeps
Optional
public readonly installDeps: boolean;
- Type: boolean
- Default: false
Install project dependencies before running commands. checkoutRepo
must also be set to true.
Currently only supported for NodeProject
.
runsOn
Optional
public readonly runsOn: string[];
- Type: string[]
- Default: ["ubuntu-latest"]
Github Runner selection labels.
runsOnGroup
Optional
public readonly runsOnGroup: GroupRunnerOptions;
- Type: projen.GroupRunnerOptions
Github Runner Group selection options.
tools
Optional
public readonly tools: Tools;
- Type: projen.github.workflows.Tools
Tools that should be installed before the commands are run.
AddPostBuildJobTaskOptions
Options for BuildWorkflow.addPostBuildJobTask
.
Initializer
import { build } from 'projen'
const addPostBuildJobTaskOptions: build.AddPostBuildJobTaskOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string[] | Github Runner selection labels. |
| projen.GroupRunnerOptions | Github Runner Group selection options. |
| projen.github.workflows.Tools | Tools that should be installed before the task is run. |
runsOn
Optional
public readonly runsOn: string[];
- Type: string[]
- Default: ["ubuntu-latest"]
Github Runner selection labels.
runsOnGroup
Optional
public readonly runsOnGroup: GroupRunnerOptions;
- Type: projen.GroupRunnerOptions
Github Runner Group selection options.
tools
Optional
public readonly tools: Tools;
- Type: projen.github.workflows.Tools
Tools that should be installed before the task is run.
BuildWorkflowCommonOptions
Initializer
import { build } from 'projen'
const buildWorkflowCommonOptions: build.BuildWorkflowCommonOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | Name of the buildfile (e.g. "build" becomes "build.yml"). |
| projen.github.workflows.JobPermissions | Permissions granted to the build job To limit job permissions for contents , the desired permissions have to be explicitly set, e.g.: { contents: JobPermission.NONE } . |
| projen.github.workflows.JobStep[] | Steps to execute before the build. |
| projen.github.workflows.Triggers | Build workflow triggers. |
name
Optional
public readonly name: string;
- Type: string
- Default: "build"
Name of the buildfile (e.g. "build" becomes "build.yml").
permissions
Optional
public readonly permissions: JobPermissions;
- Type: projen.github.workflows.JobPermissions
- Default:
{ contents: JobPermission.WRITE }
Permissions granted to the build job To limit job permissions for contents
, the desired permissions have to be explicitly set, e.g.: { contents: JobPermission.NONE }
.
preBuildSteps
Optional
public readonly preBuildSteps: JobStep[];
- Type: projen.github.workflows.JobStep[]
- Default: []
Steps to execute before the build.
workflowTriggers
Optional
public readonly workflowTriggers: Triggers;
- Type: projen.github.workflows.Triggers
- Default: "{ pullRequest: {}, workflowDispatch: {} }"
Build workflow triggers.
BuildWorkflowOptions
Initializer
import { build } from 'projen'
const buildWorkflowOptions: build.BuildWorkflowOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | Name of the buildfile (e.g. "build" becomes "build.yml"). |
| projen.github.workflows.JobPermissions | Permissions granted to the build job To limit job permissions for contents , the desired permissions have to be explicitly set, e.g.: { contents: JobPermission.NONE } . |
| projen.github.workflows.JobStep[] | Steps to execute before the build. |
| projen.github.workflows.Triggers | Build workflow triggers. |
| projen.Task | The task to execute in order to build the project. |
| string | A name of a directory that includes build artifacts. |
| string | The container image to use for builds. |
| {[ key: string ]: string} | Build environment variables. |
| projen.github.GitIdentity | Git identity to use for the workflow. |
| boolean | Automatically update files modified during builds to pull-request branches. |
| projen.github.workflows.JobStep[] | Steps to execute after build. |
| string[] | Github Runner selection labels. |
| projen.GroupRunnerOptions | Github Runner Group selection options. |
name
Optional
public readonly name: string;
- Type: string
- Default: "build"
Name of the buildfile (e.g. "build" becomes "build.yml").
permissions
Optional
public readonly permissions: JobPermissions;
- Type: projen.github.workflows.JobPermissions
- Default:
{ contents: JobPermission.WRITE }
Permissions granted to the build job To limit job permissions for contents
, the desired permissions have to be explicitly set, e.g.: { contents: JobPermission.NONE }
.
preBuildSteps
Optional
public readonly preBuildSteps: JobStep[];
- Type: projen.github.workflows.JobStep[]
- Default: []
Steps to execute before the build.
workflowTriggers
Optional
public readonly workflowTriggers: Triggers;
- Type: projen.github.workflows.Triggers
- Default: "{ pullRequest: {}, workflowDispatch: {} }"
Build workflow triggers.
buildTask
Required
public readonly buildTask: Task;
- Type: projen.Task
The task to execute in order to build the project.
artifactsDirectory
Optional
public readonly artifactsDirectory: string;
- Type: string
- Default: "dist"
A name of a directory that includes build artifacts.
containerImage
Optional
public readonly containerImage: string;
- Type: string
- Default: the default workflow container
The container image to use for builds.
env
Optional
public readonly env: {[ key: string ]: string};
- Type: {[ key: string ]: string}
- Default: {}
Build environment variables.
gitIdentity
Optional
public readonly gitIdentity: GitIdentity;
- Type: projen.github.GitIdentity
- Default: default identity
Git identity to use for the workflow.
mutableBuild
Optional
public readonly mutableBuild: boolean;
- Type: boolean
- Default: true
Automatically update files modified during builds to pull-request branches.
This means that any files synthesized by projen or e.g. test snapshots will always be up-to-date before a PR is merged.
Implies that PR builds do not have anti-tamper checks.
This is enabled by default only if githubTokenSecret
is set. Otherwise it
is disabled, which implies that file changes that happen during build will
not be pushed back to the branch.
postBuildSteps
Optional
public readonly postBuildSteps: JobStep[];
- Type: projen.github.workflows.JobStep[]
- Default: []
Steps to execute after build.
runsOn
Optional
public readonly runsOn: string[];
- Type: string[]
- Default: ["ubuntu-latest"]
Github Runner selection labels.
runsOnGroup
Optional
public readonly runsOnGroup: GroupRunnerOptions;
- Type: projen.GroupRunnerOptions
Github Runner Group selection options.