shicky
shicky

Reputation: 2126

How can I trigger a pipeline from the circleCI web app using parameters?

I'm trying to achieve something in CircleCI that seemed relatively simple in the past with Jenkins etc but is proving a little more difficult here.

At a high-level, I want to look at a certain branch in circleCI, then trigger a pipeline which will take a small number of parameters and basically run our Selenium tests against a specific environment.

I found the following docs which looked promising - https://circleci.com/docs/triggers-overview/#run-a-pipeline-from-the-circleci-web-app

However, it's pretty light on detail.

Here's my attempt at a solution:

  on_demand_test_run_on_env:
when:
  equal: [ true, << pipeline.parameters.on_demand_test_run >> ]
jobs:
  - checkout_branch
  - feature_tests:
      name: Parallel Tests
      parallelism: 10
      feature_paths: features/parallel_tests
      tags: << pipeline.parameters.on_demand_cucumber_tags >>
      context: nightly_run
      requires:
        - checkout_branch
  - feature_tests:
      name: Serial Tests
      parallelism: 10
      feature_paths: features/serial_tests
      tags: << pipeline.parameters.on_demand_cucumber_tags >>
      context: nightly_run
      requires:
        - checkout_branch

I have a few problems:

  1. CircleCI config validate now fails as those variables are unknown, do I need to provide a default empty value in the yml? I'd prefer not to given this should only trigger from manual effort.
  2. I want to provide an environment variable from the user-input parameters in circleCI to the feature_tests jobs definition, is this possible and will it work?

In my head this is something simple like:

feature_tests:
 environment:
  test_environment: << parameters.on_demand_test_environment >>

However, I'm worried this won't work with how parameters are evaluated

Upvotes: 0

Views: 979

Answers (1)

shicky
shicky

Reputation: 2126

Surprisingly, this did actually work!

For problem 1 I did need to provide default parameter types/values to get a valid circleci config

For problem 2, there was simply no issue for my needs anyway

Upvotes: 0

Related Questions