Skip to main content
Pulumi logo Pulumi logo
  1. Docs
  2. Delivery
  3. Concepts
  4. Sources and triggers

Sources and triggers

    A source tells Pulumi Delivery where a release’s code comes from. Every stack update and job checks out a source. A release is the set of commits, one per source, that a run deploys. A trigger on a source decides whether a change to it starts a new run.

    Repository sources

    Delivery has one source resource per version control provider. Each takes a repository and a branch:

    Resourcerepository format
    GitHubSourceowner/repo
    GitLabSourcegroup/subgroup/repo, the full path
    BitbucketSourceworkspace/repo
    AzureDevOpsSourceorg/project/repo

    Pulumi Cloud uses your organization’s version control integration to interact with your source code provider. You’ll need to give that integration access to every repository you use in your pipelines, including the repository containing the pipeline program itself.

    When a run is created, Pulumi Delivery fetches the code from each source and pins the run to one commit from each. Every stage of the run uses those pinned commits, so the code stays the same as the release moves through the pipeline, even if new commits land in the meantime.

    Declare sources directly, not inside code that waits for a stack or job output. A source that appears only after a stack update or job finishes is too late to be pinned, and the run fails.

    Pipeline sources

    A PipelineSource reads the release that a stage of another pipeline deployed. It’s how a downstream pipeline picks up values, such as a cluster endpoint, that an upstream pipeline published as artifacts.

    const platform = new delivery.PipelineSource("platform", {
        pipeline: "platform-delivery/main",
        stage: "prod",
        trigger: true,
    });
    
    platform = delivery.PipelineSource(
        "platform",
        pipeline="platform-delivery/main",
        stage="prod",
        trigger=True,
    )
    
    platform, err := delivery.NewPipelineSource(ctx, "platform", &delivery.PipelineSourceArgs{
    	Pipeline: pulumi.String("platform-delivery/main"),
    	Stage:    pulumi.String("prod"),
    	Trigger:  pulumi.Bool(true),
    })
    if err != nil {
    	return err
    }
    
    var platform = new PipelineSource("platform", new PipelineSourceArgs
    {
        Pipeline = "platform-delivery/main",
        Stage = "prod",
        Trigger = true,
    });
    
    var platform = new PipelineSource("platform", PipelineSourceArgs.builder()
        .pipeline("platform-delivery/main")
        .stage("prod")
        .trigger(true)
        .build());
    
    resources:
      platform:
        type: delivery:PipelineSource
        properties:
          pipeline: platform-delivery/main
          stage: prod
          trigger: true
    
    resource "delivery_pipeline_source" "platform" {
      pipeline = "platform-delivery/main"
      stage    = "prod"
      trigger  = true
    }
    

    To learn more, see Connecting pipelines.

    Triggers

    A trigger on a source decides whether a change to that source starts a new run.

    To start a run on every push to the branch, set trigger: true. To start a run only when a push changes certain files, set trigger to { paths: [...] } with a list of glob patterns:

    const app = new delivery.GitHubSource("app", {
        repository: "acme/shop",
        branch: "main",
        trigger: { paths: ["src/**", "delivery/**"] },
    });
    
    app = delivery.GitHubSource(
        "app",
        repository="acme/shop",
        branch="main",
        trigger={"paths": ["src/**", "delivery/**"]},
    )
    
    app, err := delivery.NewGitHubSource(ctx, "app", &delivery.GitHubSourceArgs{
    	Repository: pulumi.String("acme/shop"),
    	Branch:     pulumi.String("main"),
    	Trigger: delivery.SourceTriggerArgs{
    		Paths: pulumi.StringArray{pulumi.String("src/**"), pulumi.String("delivery/**")},
    	},
    })
    if err != nil {
    	return err
    }
    
    var app = new GitHubSource("app", new GitHubSourceArgs
    {
        Repository = "acme/shop",
        Branch = "main",
        Trigger = new SourceTriggerArgs { Paths = { "src/**", "delivery/**" } },
    });
    
    var app = new GitHubSource("app", GitHubSourceArgs.builder()
        .repository("acme/shop")
        .branch("main")
        .trigger(SourceTriggerArgs.builder()
            .paths("src/**", "delivery/**")
            .build())
        .build());
    
    resources:
      app:
        type: delivery:GitHubSource
        properties:
          repository: acme/shop
          branch: main
          trigger:
            paths:
              - src/**
              - delivery/**
    
    resource "delivery_git_hub_source" "app" {
      repository = "acme/shop"
      branch     = "main"
      trigger = {
        paths = ["src/**", "delivery/**"]
      }
    }
    

    On a PipelineSource, trigger: true starts a run whenever the named upstream stage deploys a new release.

    A source without a trigger is still part of the release, but changes to it never start a run.

    Other ways to start a run

    You can also start a run from Start a run in the Pulumi Cloud console, or through the REST API. You can locally run on a pipeline program by running pulumi up on the pipeline stack.

    To start a run through the REST API:

    curl -X POST \
        -H "Authorization: token $PULUMI_ACCESS_TOKEN" \
        -H "Content-Type: application/json" \
        -d '{}' \
        https://api.pulumi.com/api/preview/stacks/acme/shop-delivery/main/delivery/dispatch
    

    Next steps

      The infrastructure platform for humans and agents.