diff --git a/.circleci/config.yml b/.circleci/config.yml index 44ef265d63f..fddbaa9c48f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,6 +4,19 @@ orbs: setup: true version: 2.1 +parameters: + persist-artifacts: + type: boolean + default: false + +_should_persist_artifacts: &should-persist-artifacts + or: + - equal: [<< pipeline.git.branch >>, "develop"] + - matches: + pattern: /^release\/.*/ + value: << pipeline.git.branch >> + - << pipeline.parameters.persist-artifacts >> + workflows: setup-workflow: jobs: @@ -151,8 +164,18 @@ jobs: echo "❌ Primary workflow definition not found in .circleci/packed/pipeline.yml!" exit 1 fi - - continuation/continue: - configuration_path: .circleci/packed/pipeline.yml + - when: + condition: *should-persist-artifacts + steps: + - continuation/continue: + configuration_path: .circleci/packed/pipeline.yml + parameters: '{ "persist-artifacts": true }' + - unless: + condition: *should-persist-artifacts + steps: + - continuation/continue: + configuration_path: .circleci/packed/pipeline.yml + parameters: '{ "persist-artifacts": false }' diff --git a/.circleci/src/pipeline/@pipeline.yml b/.circleci/src/pipeline/@pipeline.yml index c0ffc69c1b9..807d546b8ca 100644 --- a/.circleci/src/pipeline/@pipeline.yml +++ b/.circleci/src/pipeline/@pipeline.yml @@ -17,6 +17,11 @@ ubuntu-2004-older: &ubuntu-2004-older ubuntu-2004:2024.05.1 orbs: browser-tools: circleci/browser-tools@2.1.1 +parameters: + persist-artifacts: + type: boolean + default: false + defaults: &defaults parallelism: 1 working_directory: ~/cypress @@ -108,28 +113,6 @@ executors: PLATFORM: linux commands: - # This command inserts SHOULD_PERSIST_ARTIFACTS into BASH_ENV. This way, we can define the variable in one place and use it in multiple steps. - # Run this command in a job before you want to use the SHOULD_PERSIST_ARTIFACTS variable. - setup_should_persist_artifacts: - steps: - - run: - name: Set environment variable to determine whether or not to persist artifacts - command: | - echo "Setting SHOULD_PERSIST_ARTIFACTS variable" - echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "fix/dbus-messages" ]]; then - export SHOULD_PERSIST_ARTIFACTS=true - fi' >> "$BASH_ENV" - # You must run `setup_should_persist_artifacts` command and be using bash before running this command - verify_should_persist_artifacts: - steps: - - run: - name: Check current branch to persist artifacts - command: | - if [[ -z "$SHOULD_PERSIST_ARTIFACTS" ]]; then - echo "Not uploading artifacts or posting install comment for this branch." - circleci-agent step halt - fi - maybe_skip_binary_jobs: steps: - run: @@ -1369,7 +1352,7 @@ commands: name: "Trigger publish-binary pipeline" command: | source ./scripts/ensure-node.sh - echo $SHOULD_PERSIST_ARTIFACTS + [[ "<< pipeline.parameters.persist-artifacts >>" == "true" ]] && export SHOULD_PERSIST_ARTIFACTS=true node ./scripts/binary/trigger-publish-binary-pipeline.js - persist_to_workspace: root: ~/ @@ -2453,10 +2436,11 @@ jobs: - build-and-package-binary - build-cypress-npm-package: executor: << parameters.executor >> - - setup_should_persist_artifacts - - verify_should_persist_artifacts - - upload-build-artifacts - - post-install-comment + - when: + condition: << pipeline.parameters.persist-artifacts >> + steps: + - upload-build-artifacts + - post-install-comment create-and-trigger-packaging-artifacts: <<: *defaults @@ -2470,7 +2454,6 @@ jobs: - maybe_skip_binary_jobs - restore_cached_workspace - check-if-binary-exists - - setup_should_persist_artifacts - trigger-publish-binary-pipeline get-published-artifacts: @@ -2487,7 +2470,6 @@ jobs: - run: name: Check pipeline info command: cat ~/triggered_pipeline.json - - setup_should_persist_artifacts - run: name: Download binary artifacts command: | @@ -2498,15 +2480,17 @@ jobs: paths: - cypress/cypress.zip - cypress/cypress.tgz - - verify_should_persist_artifacts - - persist_to_workspace: - root: ~/ - paths: - - cypress/binary-url.json - - cypress/npm-package-url.json - - post-install-comment: - package_url_path: ~/cypress/npm-package-url.json - binary_url_path: ~/cypress/binary-url.json + - when: + condition: << pipeline.parameters.persist-artifacts >> + steps: + - persist_to_workspace: + root: ~/ + paths: + - cypress/binary-url.json + - cypress/npm-package-url.json + - post-install-comment: + package_url_path: ~/cypress/npm-package-url.json + binary_url_path: ~/cypress/binary-url.json test-kitchensink: <<: *defaults