From 8ba5bcd28356fbafecfc1be9e775af0c97894e58 Mon Sep 17 00:00:00 2001 From: Tomas Bjerre Date: Fri, 16 Nov 2018 20:40:12 +0100 Subject: [PATCH] Adding example of ignoring push event with zero commits --- CHANGELOG.md | 19 ++++ .../jenkinsci/plugins/gwt/bdd/Stepdefs.java | 2 - ...-push-ignore-create-remove-branch.feature} | 0 ...gitlab-push-ignore-when-no-commits.feature | 102 ++++++++++++++++++ 4 files changed, 121 insertions(+), 2 deletions(-) rename src/test/resources/org/jenkinsci/plugins/gwt/bdd/gitlab/{gitlab-push-ignore-create-branch.feature => gitlab-push-ignore-create-remove-branch.feature} (100%) create mode 100644 src/test/resources/org/jenkinsci/plugins/gwt/bdd/gitlab/gitlab-push-ignore-when-no-commits.feature diff --git a/CHANGELOG.md b/CHANGELOG.md index 8edce8c..f8ef01e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Generic Webhook Plugin Changelog Changelog of Generic Webhook Plugin. +## Unreleased +### No issue + +**Adding example of ignoring push event with zero commits** + + +[1b8e9b3a25fe7a7](https://github.com/jenkinsci/generic-webhook-trigger-plugin/commit/1b8e9b3a25fe7a7) Tomas Bjerre *2018-11-16 19:40:12* + +**Example of ignoring removal or creation of branches** + + +[108723a32c7c5ec](https://github.com/jenkinsci/generic-webhook-trigger-plugin/commit/108723a32c7c5ec) Tomas Bjerre *2018-11-16 19:28:24* + +**Documenting trigger on changed folder GitLab** + + +[a4713a8b6532496](https://github.com/jenkinsci/generic-webhook-trigger-plugin/commit/a4713a8b6532496) Tomas Bjerre *2018-11-15 18:13:36* + + ## 1.48 (2018-11-08 17:47:29) ### GitHub [#88](https://github.com/jenkinsci/generic-webhook-trigger-plugin/pull/88) Use the job's configured quiet period diff --git a/src/test/java/org/jenkinsci/plugins/gwt/bdd/Stepdefs.java b/src/test/java/org/jenkinsci/plugins/gwt/bdd/Stepdefs.java index 486490d..079c88a 100644 --- a/src/test/java/org/jenkinsci/plugins/gwt/bdd/Stepdefs.java +++ b/src/test/java/org/jenkinsci/plugins/gwt/bdd/Stepdefs.java @@ -13,8 +13,6 @@ import java.util.List; import java.util.Map; import java.util.logging.Logger; - -import org.assertj.core.api.Assertions; import org.jenkinsci.plugins.gwt.ExpressionType; import org.jenkinsci.plugins.gwt.GenericVariable; import org.jenkinsci.plugins.gwt.Renderer; diff --git a/src/test/resources/org/jenkinsci/plugins/gwt/bdd/gitlab/gitlab-push-ignore-create-branch.feature b/src/test/resources/org/jenkinsci/plugins/gwt/bdd/gitlab/gitlab-push-ignore-create-remove-branch.feature similarity index 100% rename from src/test/resources/org/jenkinsci/plugins/gwt/bdd/gitlab/gitlab-push-ignore-create-branch.feature rename to src/test/resources/org/jenkinsci/plugins/gwt/bdd/gitlab/gitlab-push-ignore-create-remove-branch.feature diff --git a/src/test/resources/org/jenkinsci/plugins/gwt/bdd/gitlab/gitlab-push-ignore-when-no-commits.feature b/src/test/resources/org/jenkinsci/plugins/gwt/bdd/gitlab/gitlab-push-ignore-when-no-commits.feature new file mode 100644 index 0000000..f8737a4 --- /dev/null +++ b/src/test/resources/org/jenkinsci/plugins/gwt/bdd/gitlab/gitlab-push-ignore-when-no-commits.feature @@ -0,0 +1,102 @@ +Feature: It should be possible to trigger for GitLab push events and ignore branch creation. + + Scenario: Push events happens. + + Given the following generic variables are configured: + | variable | expression | expressionType | defaultValue | regexpFilter | + | object_kind | $.object_kind | JSONPath | | | + | after | $.after | JSONPath | | | + | total_commits_count | $.total_commits_count | JSONPath | | | + | ref | $.ref | JSONPath | | | + | git_ssh_url | $.repository.git_ssh_url | JSONPath | | | + + Given filter is configured with text: $object_kind $after $total_commits_count + Given filter is configured with expression: ^push\s.{40}\s[^0].* + + + When received post content is: + """ + { + "object_kind": "push", + "after": "f34c80f418afb802094f1ba42ad0ec1a20c7a02s", + "ref": "refs/heads/master", + "total_commits_count": 0, + "repository":{ + "git_ssh_url":"git@example.com:mike/diaspora.git", + } + } + """ + Then the job is not triggered + Then variables are resolved to: + | variable | value | + | object_kind | push | + | after | f34c80f418afb802094f1ba42ad0ec1a20c7a02s | + | total_commits_count | 0 | + | ref | refs/heads/master | + | git_ssh_url | git@example.com:mike/diaspora.git | + + + When received post content is: + """ + { + "object_kind": "push", + "after": "f34c80f418afb802094f1ba42ad0ec1a20c7a02s", + "ref": "refs/heads/master", + "total_commits_count": 1, + "repository":{ + "git_ssh_url":"git@example.com:mike/diaspora.git", + } + } + """ + Then the job is triggered + Then variables are resolved to: + | variable | value | + | object_kind | push | + | after | f34c80f418afb802094f1ba42ad0ec1a20c7a02s | + | total_commits_count | 1 | + | ref | refs/heads/master | + | git_ssh_url | git@example.com:mike/diaspora.git | + + + When received post content is: + """ + { + "object_kind": "push", + "after": "f34c80f418afb802094f1ba42ad0ec1a20c7a02s", + "ref": "refs/heads/master", + "total_commits_count": 10, + "repository":{ + "git_ssh_url":"git@example.com:mike/diaspora.git", + } + } + """ + Then the job is triggered + Then variables are resolved to: + | variable | value | + | object_kind | push | + | after | f34c80f418afb802094f1ba42ad0ec1a20c7a02s | + | total_commits_count | 10 | + | ref | refs/heads/master | + | git_ssh_url | git@example.com:mike/diaspora.git | + + + When received post content is: + """ + { + "object_kind": "push", + "after": "f34c80f418afb802094f1ba42ad0ec1a20c7a02s", + "ref": "refs/heads/master", + "total_commits_count": 123, + "repository":{ + "git_ssh_url":"git@example.com:mike/diaspora.git", + } + } + """ + Then the job is triggered + Then variables are resolved to: + | variable | value | + | object_kind | push | + | after | f34c80f418afb802094f1ba42ad0ec1a20c7a02s | + | total_commits_count | 123 | + | ref | refs/heads/master | + | git_ssh_url | git@example.com:mike/diaspora.git |