Change custom parameter in yaml for specific workflow

46 Views Asked by At

There are two workflows which are triggered based on specific conditions and I need to change custom parameter in case one of the workflow is triggered. I created custom parameter isFeatureBranch == FALSE by default. Also I have two workflows (feature_branch and nightly). I need to change isFeatureBranch == TRUE in case feature_branch is triggered

Here's my yaml file

version: 2.1

orbs:
  gcp-cli: circleci/[email protected]

parameters:
  isFeatureBranch:
    type: boolean
    default: false

jobs:
  run_browserstack:
    docker:
      - image: cypress/base:16.14.2-slim
    steps:
      - checkout
      - run:
          name: Install curl
          command: apt-get update && apt-get install -y curl
workflows:
  feature_branch:
    jobs:
      - run_browserstack:
          context:
            - automation
          filters:
            branches:
              ignore:
                - master
  nightly:
    jobs:
      - run_browserstack:
          context:
            - automation

Here's what i tried

workflows:
  feature_branch:
    jobs:
      - run_browserstack:
          context:
            - automation
          filters:
            branches:
              ignore:
                - master
    # Change parameter for isFeatureBranch if feature_branch workflow is triggered
    parameters:
      isFeatureBranch:
        type: boolean
        default: true 
  nightly:
    jobs:
      - run_browserstack:
          context:
            - automation
1

There are 1 best solutions below

1
Chewie On

How about splitting it into two jobs? You could create a stage and inside this stage execute a job after the other. like:

-stage: stageName
 displayName: Stage Name
 jobs:
 - ${{ if eq(something, 'something') }} <you may include if conditions before the job if needed>
  - job: firstJob
     <job code>
  - job: secondJob
     <job code>