Class Job.Builder
- java.lang.Object
-
- io.github.cdklabs.projen.github.workflows.Job.Builder
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
-
-
-
Method Detail
-
steps
@Stability(Experimental) public Job.Builder steps(List<? extends JobStep> steps)
Sets the value ofJob.getSteps()- Parameters:
steps- A job contains a sequence of tasks called steps. This parameter is required. Steps can run commands, run setup tasks, or run an action in your repository, a public repository, or an action published in a Docker registry. Not all steps run actions, but all actions run as a step. Each step runs in its own process in the runner environment and has access to the workspace and filesystem. Because steps run in their own process, changes to environment variables are not preserved between steps. GitHub provides built-in steps to set up and complete a job.- Returns:
this
-
container
@Stability(Experimental) public Job.Builder container(ContainerOptions container)
Sets the value ofJob.getContainer()- Parameters:
container- A container to run any steps in a job that don't already specify a container. If you have steps that use both script and container actions, the container actions will run as sibling containers on the same network with the same volume mounts.- Returns:
this
-
continueOnError
@Stability(Experimental) public Job.Builder continueOnError(Boolean continueOnError)
Sets the value ofJob.getContinueOnError()- Parameters:
continueOnError- Prevents a workflow run from failing when a job fails. Set to true to allow a workflow run to pass when this job fails.- Returns:
this
-
defaults
@Stability(Experimental) public Job.Builder defaults(JobDefaults defaults)
Sets the value ofJob.getDefaults()- Parameters:
defaults- A map of default settings that will apply to all steps in the job. You can also set default settings for the entire workflow.- Returns:
this
-
env
@Stability(Experimental) public Job.Builder env(Map<String,String> env)
Sets the value ofJob.getEnv()- Parameters:
env- A map of environment variables that are available to all steps in the job. You can also set environment variables for the entire workflow or an individual step.- Returns:
this
-
environment
@Stability(Experimental) public Job.Builder environment(Object environment)
Sets the value ofJob.getEnvironment()- Parameters:
environment- The environment that the job references. All environment protection rules must pass before a job referencing the environment is sent to a runner.- Returns:
this
-
outputs
@Stability(Experimental) public Job.Builder outputs(Map<String,? extends JobStepOutput> outputs)
Sets the value ofJob.getOutputs()- Parameters:
outputs- A map of outputs for a job. Job outputs are available to all downstream jobs that depend on this job.- Returns:
this
-
runsOn
@Stability(Experimental) public Job.Builder runsOn(List<String> runsOn)
Sets the value ofJob.getRunsOn()- Parameters:
runsOn- The type of machine to run the job on. The machine can be either a GitHub-hosted runner or a self-hosted runner.- Returns:
this
-
runsOnGroup
@Stability(Experimental) public Job.Builder runsOnGroup(GroupRunnerOptions runsOnGroup)
Sets the value ofJob.getRunsOnGroup()- Parameters:
runsOnGroup- Github Runner Group selection options.- Returns:
this
-
services
@Stability(Experimental) public Job.Builder services(Map<String,? extends ContainerOptions> services)
Sets the value ofJob.getServices()- Parameters:
services- Used to host service containers for a job in a workflow. Service containers are useful for creating databases or cache services like Redis. The runner automatically creates a Docker network and manages the life cycle of the service containers.- Returns:
this
-
timeoutMinutes
@Stability(Experimental) public Job.Builder timeoutMinutes(Number timeoutMinutes)
Sets the value ofJob.getTimeoutMinutes()- Parameters:
timeoutMinutes- The maximum number of minutes to let a job run before GitHub automatically cancels it.- Returns:
this
-
tools
@Stability(Experimental) public Job.Builder tools(Tools tools)
Sets the value ofJob.getTools()- Parameters:
tools- Tools required for this job. Translates intoactions/setup-xxxsteps at the beginning of the job.- Returns:
this
-
permissions
@Stability(Experimental) public Job.Builder permissions(JobPermissions permissions)
Sets the value ofCommonJobDefinition.getPermissions()- Parameters:
permissions- You can modify the default permissions granted to the GITHUB_TOKEN, adding or removing access as required, so that you only allow the minimum required access. This parameter is required. Use{ contents: READ }if your job only needs to clone code.This is intentionally a required field since it is required in order to allow workflows to run in GitHub repositories with restricted default access.
- Returns:
this
-
concurrency
@Stability(Experimental) public Job.Builder concurrency(Object concurrency)
Sets the value ofCommonJobDefinition.getConcurrency()- Parameters:
concurrency- Concurrency ensures that only a single job or workflow using the same concurrency group will run at a time. A concurrency group can be any string or expression. The expression can use any context except for the secrets context.- Returns:
this
-
ifValue
@Stability(Experimental) public Job.Builder ifValue(String ifValue)
Sets the value ofCommonJobDefinition.getIfValue()- Parameters:
ifValue- You can use the if conditional to prevent a job from running unless a condition is met. You can use any supported context and expression to create a conditional.- Returns:
this
-
name
@Stability(Experimental) public Job.Builder name(String name)
Sets the value ofCommonJobDefinition.getName()- Parameters:
name- The name of the job displayed on GitHub.- Returns:
this
-
needs
@Stability(Experimental) public Job.Builder needs(List<String> needs)
Sets the value ofCommonJobDefinition.getNeeds()- Parameters:
needs- Identifies any jobs that must complete successfully before this job will run. It can be a string or array of strings. If a job fails, all jobs that need it are skipped unless the jobs use a conditional expression that causes the job to continue.- Returns:
this
-
strategy
@Stability(Experimental) public Job.Builder strategy(JobStrategy strategy)
Sets the value ofCommonJobDefinition.getStrategy()- Parameters:
strategy- A strategy creates a build matrix for your jobs. You can define different variations to run each job in.- Returns:
this
-
build
@Stability(Experimental) public Job build()
Builds the configured instance.- Specified by:
buildin interfacesoftware.amazon.jsii.Builder<Job>- Returns:
- a new instance of
Job - Throws:
NullPointerException- if any required attribute was not provided
-
-