From 4176dfa880d02e6898a9d19d929bfeab8d87388a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michel=20D=C3=A4nzer?= Date: Fri, 3 Apr 2020 11:46:12 +0200 Subject: [PATCH] gitlab-ci: Run merge request pipelines automatically only for Marge Bot MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit MR pipelines not triggered by Marge Bot can still be triggered manually. Motivation: The main & forked Mesa project CI pipelines combined are currently generating over 1 TB of egress traffic per week. ~80% of this is from pre-merge pipelines. Assuming this corresponds to 4 pre-merge and one post-merge pipeline per MR on average, this change could potentially eliminate up to ~60% of the overall traffic (by preventing 3 of the 4 pre-merge pipelines from running automatically). (Of course, this could be subverted if all jobs of the other pipelines were triggered manually anyway... In most cases, manually triggering just a few jobs should suffice) v2: * $GITLAB_USER_NAME was the wrong variable, $GITLAB_USER_LOGIN should do the trick. Suggested-by: Marek Olšák Reviewed-by: Adam Jackson Acked-by: Alyssa Rosenzweig Reviewed-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Samuel Pitoiset Tested-by: Marge Bot Part-of: --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dcdb06a2a5a..9834541afac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -100,9 +100,9 @@ success: extends: - .ci-run-policy rules: - # Run pipeline by default if it is for a merge request and any files - # affecting it were changed - - if: '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == $CI_COMMIT_REF_NAME' + # Run pipeline by default if it was triggered by Marge Bot, is for a + # merge request, and any files affecting it were changed + - if: '$GITLAB_USER_LOGIN == "marge-bot" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == $CI_COMMIT_REF_NAME' changes: *all_paths when: on_success @@ -112,9 +112,9 @@ success: changes: *all_paths when: on_success - # Allow triggering jobs manually for branches of forked projects - - if: '$CI_PROJECT_PATH != "mesa/mesa" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME != $CI_COMMIT_REF_NAME' - changes: + # Allow triggering jobs manually for MRs or branches of forked projects if + # any files affecting the pipeline were changed + - changes: *all_paths when: manual # Otherwise, container jobs won't run -- 2.30.2