Skip to content

Pass parameters into a pipeline #571

Closed

Description

@roberttriggs

Hi,
I am really interested in this library, looking for some guidance on running mutliple pipelines with run specific parameters - my use case requires the same pipeline to run multiple times based on specific run parameters (e.q. from build queue to produce a pipeline run per customer)
so the pipeline steps are the same but passing in build parameters to make the run specific to the customer based on their build Params (these params are accessed in the modules).

At the moment I am created a new pipeline each time via a createPipeLine method:

  private static PipelineHostBuilder CreateuildPipeline(BuildParameters parameters)
  {
      var pipeline = PipelineHostBuilder.Create()
                      .ConfigureAppConfiguration((context, builder) =>
                      {
                          builder.AddJsonFile("appsettings.json")
                              .AddUserSecrets<Program>()
                              .AddEnvironmentVariables();
                      }).ConfigureServices((context, collection) =>
                      {
                          collection.Configure<SiteBuildRequest>(_ => GetSiteBuildRequest(parameters));
                      });
      pipeline.AddModule<FirstStepModule>();

      return pipeline;
  }

then execute each create pipeline

await pipeline.ExecutePipelineAsync();

Would this be the best way? (Not yet tried to see happens if I try to execute more than one concurrently yet and whether there is any issue having multiple instances of the pipeline host? (also can you confirm if multiple instances of the same pipeline would be ok?)

I wondered if there could be a way like having a version of ExecutePipeline that allows a parameters class to be passed in but the underlying pipeline is the same each time.
something like:
await pipeline.ExecutePipelineAsync(buildParameters)

Activity

  1. thomhurst commented on Aug 26, 2024

    @thomhurst
    Owner

    I wondered if there could be a way like having a version of ExecutePipeline that allows a parameters class to be passed in but the underlying pipeline is the same each time.
    something like:
    await pipeline.ExecutePipelineAsync(buildParameters)

    There's nothing like this currently but there's no reason you can't create a helper method for that yourself!

    (Not yet tried to see happens if I try to execute more than one concurrently yet and whether there is any issue having multiple instances of the pipeline host? (also can you confirm if multiple instances of the same pipeline would be ok?)

    The same object/instance can't be invoked multiple times - But if you create multiple instances, they can be each invoked concurrently. I don't know how this would perform because it depends what your pipeline is doing, and how well spec'd your machine is - So that'll be trial and error on your part I guess.

    Would this be the best way?

    Yes - I don't see anything wrong with your method.

  2. Repository owner locked and limited conversation to collaborators on Aug 28, 2024
  3. converted this issue into a discussion #581 on Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions