From cd47250147b66e87f30d6704782aaae892ba0da3 Mon Sep 17 00:00:00 2001 From: Timo Beller Date: Tue, 20 Sep 2022 16:52:35 +0200 Subject: [PATCH 1/2] feat(workflow): Provides a common workflow It runs all pipelines but prevents that a branch pipelines is started when there is an open merge request. https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines --- .../templates/common/common-ci-workflow.adoc | 12 ++++++++++++ documentation/document.adoc | 1 + templates/common/common-ci-workflow.gitlab-ci.yml | 6 ++++++ 3 files changed, 19 insertions(+) create mode 100644 documentation/chapters/templates/common/common-ci-workflow.adoc create mode 100644 templates/common/common-ci-workflow.gitlab-ci.yml diff --git a/documentation/chapters/templates/common/common-ci-workflow.adoc b/documentation/chapters/templates/common/common-ci-workflow.adoc new file mode 100644 index 0000000..c515acb --- /dev/null +++ b/documentation/chapters/templates/common/common-ci-workflow.adoc @@ -0,0 +1,12 @@ +:gitlab-ci-file: common/common-ci-workflow.gitlab-ci.yml + +[[Common-Workflow]] +== Common Workflow + +Within the `{gitlab-ci-file}` file we provide a common workflow. +This workflow runs all pipelines (including branch pipelines, tag pipelines, merge request pipelines, triggerd pipelines, shedules-pipelines ...). +However, it prevents that a branch pipeline starts, when there is an open merge request. +To use our common workflow, just import the template. + +:template: {gitlab-ci-file} +include::../../../template-printer.adoc[] \ No newline at end of file diff --git a/documentation/document.adoc b/documentation/document.adoc index d050990..4df29c1 100644 --- a/documentation/document.adoc +++ b/documentation/document.adoc @@ -35,6 +35,7 @@ toc::[] include::generalInformation.adoc[leveloffset=1] include::chapters/templates/common/common-ci-variablen.adoc[leveloffset=1] +include::chapters/templates/common/common-ci-workflow.adoc[leveloffset=1] == Contribution diff --git a/templates/common/common-ci-workflow.gitlab-ci.yml b/templates/common/common-ci-workflow.gitlab-ci.yml new file mode 100644 index 0000000..2082b01 --- /dev/null +++ b/templates/common/common-ci-workflow.gitlab-ci.yml @@ -0,0 +1,6 @@ +workflow: + rules: + # Prevent branch pipelines when there is an open merge request + - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push" + when: never + - when: always From 97352e8270b55bf69bd14e9b922a9629ddd5897c Mon Sep 17 00:00:00 2001 From: Timo Beller Date: Thu, 6 Oct 2022 11:16:58 +0200 Subject: [PATCH 2/2] feat(workflow): Changes our common workflow to git-flow-with-merge-request According to discussion in ci-cd#237 / weekly --- .../templates/common/common-ci-workflow.adoc | 12 ------------ .../chapters/templates/common/workflow-gitflow.adoc | 11 +++++++++++ documentation/document.adoc | 2 +- templates/common/common-ci-workflow.gitlab-ci.yml | 6 ------ templates/common/workflow-gitflow.gitlab-ci.yml | 5 +++++ 5 files changed, 17 insertions(+), 19 deletions(-) delete mode 100644 documentation/chapters/templates/common/common-ci-workflow.adoc create mode 100644 documentation/chapters/templates/common/workflow-gitflow.adoc delete mode 100644 templates/common/common-ci-workflow.gitlab-ci.yml create mode 100644 templates/common/workflow-gitflow.gitlab-ci.yml diff --git a/documentation/chapters/templates/common/common-ci-workflow.adoc b/documentation/chapters/templates/common/common-ci-workflow.adoc deleted file mode 100644 index c515acb..0000000 --- a/documentation/chapters/templates/common/common-ci-workflow.adoc +++ /dev/null @@ -1,12 +0,0 @@ -:gitlab-ci-file: common/common-ci-workflow.gitlab-ci.yml - -[[Common-Workflow]] -== Common Workflow - -Within the `{gitlab-ci-file}` file we provide a common workflow. -This workflow runs all pipelines (including branch pipelines, tag pipelines, merge request pipelines, triggerd pipelines, shedules-pipelines ...). -However, it prevents that a branch pipeline starts, when there is an open merge request. -To use our common workflow, just import the template. - -:template: {gitlab-ci-file} -include::../../../template-printer.adoc[] \ No newline at end of file diff --git a/documentation/chapters/templates/common/workflow-gitflow.adoc b/documentation/chapters/templates/common/workflow-gitflow.adoc new file mode 100644 index 0000000..d886300 --- /dev/null +++ b/documentation/chapters/templates/common/workflow-gitflow.adoc @@ -0,0 +1,11 @@ +:gitlab-ci-file: common/workflow-gitflow.gitlab-ci.yml + +[[Common-Workflow]] +== Common Workflow + +Within the `{gitlab-ci-file}` file we provide our common workflow, the https://docs.gitlab.com/ee/ci/yaml/workflow.html#git-flow-with-merge-request-pipelines[Git Flow with merge request workflow]. +This workflow runs pipelines for merge requests, tags, and protected branches. +To use our common workflow, just import the template. + +:template: {gitlab-ci-file} +include::../../../template-printer.adoc[] \ No newline at end of file diff --git a/documentation/document.adoc b/documentation/document.adoc index 4df29c1..a7e4f17 100644 --- a/documentation/document.adoc +++ b/documentation/document.adoc @@ -35,7 +35,7 @@ toc::[] include::generalInformation.adoc[leveloffset=1] include::chapters/templates/common/common-ci-variablen.adoc[leveloffset=1] -include::chapters/templates/common/common-ci-workflow.adoc[leveloffset=1] +include::chapters/templates/common/workflow-gitflow.adoc[leveloffset=1] == Contribution diff --git a/templates/common/common-ci-workflow.gitlab-ci.yml b/templates/common/common-ci-workflow.gitlab-ci.yml deleted file mode 100644 index 2082b01..0000000 --- a/templates/common/common-ci-workflow.gitlab-ci.yml +++ /dev/null @@ -1,6 +0,0 @@ -workflow: - rules: - # Prevent branch pipelines when there is an open merge request - - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push" - when: never - - when: always diff --git a/templates/common/workflow-gitflow.gitlab-ci.yml b/templates/common/workflow-gitflow.gitlab-ci.yml new file mode 100644 index 0000000..e3facdb --- /dev/null +++ b/templates/common/workflow-gitflow.gitlab-ci.yml @@ -0,0 +1,5 @@ +workflow: + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + - if: $CI_COMMIT_TAG + - if: $CI_COMMIT_REF_PROTECTED