How to run/skip particular job in workflow based on runtime parameter

Hi

Need some guidance. Is that possible to run or skip particular job in workflow based on runtime parameter


version: 2.1
parameters:
  flag:
    type: string
    default: "
# Define the jobs we want to run for this project
jobs:
  build:
    docker:
      - image: cimg/<language>:<version TAG>
        auth:
          username: mydockerhub-user
          password: $DOCKERHUB_PASSWORD  # context / project UI env-var reference
    steps:
      - checkout
      - run: echo "this is the build job"
  test:
    docker:
      - image: cimg/<language>:<version TAG>
        auth:
          username: mydockerhub-user
          password: $DOCKERHUB_PASSWORD  # context / project UI env-var reference
    steps:
      - checkout
      - run: echo "this is the test job"

# Orchestrate our job run sequence
workflows:
  build_and_test:
    jobs:
      - build
      - test

Now if flag is Yes then execute job ‘test’ else skip

Is there is any way to do this ? Please suggest

You would use the structure as defined here

https://support.circleci.com/hc/en-us/articles/360043638052-Conditional-steps-in-jobs-and-conditional-workflows

As you are looking to cause one or more jobs to be conditional (rather than workflows) you need to look at the first example where the check is placed within the job definition.