From 5d5bcbbeb6c193ce135b7dbabbdfe37f4ad27c57 Mon Sep 17 00:00:00 2001 From: Jeremy Mathevet Date: Thu, 11 Jun 2020 22:06:03 +0800 Subject: [PATCH 1/2] Add cloudbuild invert regex option --- products/cloudbuild/api.yaml | 13 +++++++++++++ .../tests/resource_cloudbuild_trigger_test.go | 2 ++ 2 files changed, 15 insertions(+) diff --git a/products/cloudbuild/api.yaml b/products/cloudbuild/api.yaml index 0a96068cfba3..ecd96549f0bd 100644 --- a/products/cloudbuild/api.yaml +++ b/products/cloudbuild/api.yaml @@ -133,6 +133,11 @@ objects: This must be a relative path. If a step's dir is specified and is an absolute path, this value is ignored for that step's execution. + + - !ruby/object:Api::Type::Boolean + name: 'invertRegex' + description: | + Only trigger a build if the revision regex does NOT match the revision regex. - !ruby/object:Api::Type::String name: 'branchName' description: | @@ -198,6 +203,10 @@ objects: values: - :COMMENTS_DISABLED - :COMMENTS_ENABLED + - !ruby/object:Api::Type::Boolean + name: 'invertRegex' + description: | + If true, branches that do NOT match the git_ref will trigger a build. - !ruby/object:Api::Type::NestedObject name: 'push' description: | @@ -206,6 +215,10 @@ objects: - github.0.pull_request - github.0.push properties: + - !ruby/object:Api::Type::Boolean + name: 'invertRegex' + description: | + When true, only trigger a build if the revision regex does NOT match the git_ref regex. - !ruby/object:Api::Type::String name: 'branch' description: | diff --git a/third_party/terraform/tests/resource_cloudbuild_trigger_test.go b/third_party/terraform/tests/resource_cloudbuild_trigger_test.go index d3c4e7ccdfa3..50595be2c2ac 100644 --- a/third_party/terraform/tests/resource_cloudbuild_trigger_test.go +++ b/third_party/terraform/tests/resource_cloudbuild_trigger_test.go @@ -194,6 +194,7 @@ resource "google_cloudbuild_trigger" "build_trigger" { trigger_template { branch_name = "master" repo_name = "some-repo" + invertRegex = false } build { images = ["gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA"] @@ -221,6 +222,7 @@ resource "google_cloudbuild_trigger" "build_trigger" { trigger_template { branch_name = "master-updated" repo_name = "some-repo-updated" + invertRegex = true } build { images = ["gcr.io/$PROJECT_ID/$REPO_NAME:$SHORT_SHA"] From 3862abe4c73ebe0fa9005defc1dfd772de83a2fd Mon Sep 17 00:00:00 2001 From: Jeremy Mathevet Date: Mon, 15 Jun 2020 11:02:27 +0800 Subject: [PATCH 2/2] Fix invert_regex name in tf tests --- .../terraform/tests/resource_cloudbuild_trigger_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/terraform/tests/resource_cloudbuild_trigger_test.go b/third_party/terraform/tests/resource_cloudbuild_trigger_test.go index 50595be2c2ac..e00c347f4a62 100644 --- a/third_party/terraform/tests/resource_cloudbuild_trigger_test.go +++ b/third_party/terraform/tests/resource_cloudbuild_trigger_test.go @@ -194,7 +194,7 @@ resource "google_cloudbuild_trigger" "build_trigger" { trigger_template { branch_name = "master" repo_name = "some-repo" - invertRegex = false + invert_regex = false } build { images = ["gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA"] @@ -222,7 +222,7 @@ resource "google_cloudbuild_trigger" "build_trigger" { trigger_template { branch_name = "master-updated" repo_name = "some-repo-updated" - invertRegex = true + invert_regex = true } build { images = ["gcr.io/$PROJECT_ID/$REPO_NAME:$SHORT_SHA"]