Add branch selector for pipeline simulation

What does this MR do and why?

Add branch selector for pipeline simulation

Select branch for which to simulate a pipeline. By default use the branch selected for pipeline configuration.

Changelog: added

References

Screenshots or screen recordings

Before After
Screenshot_2025-08-07_at_13.02.23 Screenshot_2025-08-18_at_17.20.47

Screen_Recording_2025-08-18_at_17.20.53

How to set up and validate locally

  1. Add a basic .gitlab-ci.yml file. Example:
variables:
  ALL_JOBS_VAR:
    value: "staging"
    options:
      - "production"
      - "staging"
      - "canary"
    description: "The deployment target. Set to 'staging' by default."

stages:
    - deploy
    - stop
image: alpine:latest

deploy-prod:
    stage: deploy
    script:
        - sleep 10
        - echo "deploying prod"
    environment:
        name: production
        url: postgres://example.com

deploy-staging:
    stage: deploy
    script:
        - echo "deploying staging I hope"
    environment:
        name: staging
        url: https://example.com
        on_stop: stop-staging
    when: manual

stop-staging:
  stage: stop
  script:
    - echo "stopping staging"
    - echo ALL_JOBS_VAR
    - echo $ALL_JOBS_VAR
    - sleep 60
  environment:
    name: staging
    action: stop
  when: manual

deploy-development:
    stage: deploy
    script:
        - echo "deploying development"
    environment:
        name: development
        url: https://example.com
    when: manual

deploy-review:
    stage: deploy
    script:
        - echo "Deploying review/$CI_COMMIT_REF_NAME"
    environment:
        name: review/$CI_COMMIT_REF_NAME
        auto_stop_in: 1 week
    only:
        - branches
    except:
        - master
    when: manual


stop_review_app:
  script: stop-review-app
  stage: stop
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    action: stop
  rules:
    - if: $CI_MERGE_REQUEST_ID
      when: manual
  1. Visit Build -> Pipeline Editor and select Validate tab
  2. Verify the source selector is set to the current branch by default.
  3. Run the validation and verify the current branch was used as a ref for the ci_lint mutation.
  4. Select a different branch and run validation. Verify the correct branch is used as a ref for the ci_lint mutation.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #482676 (closed)

Edited by Anna Vovchenko

Merge request reports

Loading