Promotion Policy YAML

YAML specifications for the Promotion Policy defining promotion conditions to apply to the environment

Codefresh provides two options for defining manifests for promotion entities: Form mode and YAML mode.

If you prefer working with YAML, create the manifest using the example Promotion Policy YAML below, and the table with field descriptions.

Once configured and committed, the settings are saved as a Custom Resource Definition (CRD) within the Shared Configuration Repository in the GitOps Runtime specified as the Configuration Runtime.

Promotion Policy YAML example

Here’s an example of the Promotion Policy manifest. The table that follows describes the fields in the Promotion Policy manifest.

apiVersion: codefresh.io/v1beta1
kind: PromotionPolicy
metadata:
  name: demo-policy
spec:
  priority: 2
  selector:
    product:
      names:
      - trio-dev
    targetEnvironment:
      names:
      - staging
      types:
      - NON_PROD
  policy:
    action: commit
    preAction: smoke-tests
    postAction: slack-notification

Promotion Policy YAML field descriptions

Field Description Type Required/Optional
metadata.name The name of the Promotion Policy, which must conform to the naming conventions for Kubernetes resources. Useful if the name indicates the purpose of this Promotion Policy - where and how it is intended to be used. For example, productionDeployments. string Required
spec.priority The priority of the Promotion Policy, determining which Pre-Action Workflow, Action, and Post-Action Workflow are applied when evaluating policies and implementing policies when multiple Promotion Policies match the same product or environment.
The priority is ranked in ascending order, ranging from 0 or a negative number to higher values.
integer Required
spec.selector The products and target environments to which to apply the Promotion Policy.
You can define multiple products, or environments.
If neither a product nor an environment is defined for a policy, it is considered a global policy that matches all products and environments.
object Optional
spec.selector.product The product or products to which to apply or match this Promotion Policy by names.
When not defined, matches all products.
object Optional
spec.selector.product.names The name of a single product or a list of multiple products to which to apply the Promotion Policy. array Optional
spec.selector.targetEnvironment The target environments to which to apply the Promotion Policy based on the name or type.
If more than one criteria are provided, all criteria must be matched.
object Optional
spec.selector.targetEnvironment.name The name of the target environment, or the list of target environments to which to apply the Promotion Policy.
When empty, applies to all environments.
array Optional
spec.selector.targetEnvironment.type The type of target environments to which to apply the Promotion Policy. Can be one of these: PROD for production environments, or NON_PROD for any other environment such as dev, qa. array Optional
spec.properties.policy The Pre-Action Workflow, Action, and Post-Action Workflow to implement for the Promotion Policy through the action, preAction, and postAction attributes.
The Action attribute is required.
See Promotion Policy implementation logic for information on how promotion settings are used.
object Optional
spec.policy.action The action that should trigger the promotion in the target environment for this Promotion Policy.
Can be one of the following:
  • commit: Executes a commit operation on the target application.
  • pr: Executes a commit and opens a pull request for the target application.
    Useful when you need manual approval before commit.
  • none: Does not execute any action on the target application.
enum Required
spec.policy.preAction The name of the Promotion Workflow to execute before spec.policy.action. string Optional
spec.policy.postAction The name of the Promotion Workflow to execute after spec.policy.action. string Optional

Product YAML
Promotion Flow YAML
Promotion Template YAML