Skip to content

Commit 7a8cbfd

Browse files
gabemonterooatmealraisin
authored and
oatmealraisin
committed
support for gitlab and bitbucket webhooks
1 parent 6a7ea04 commit 7a8cbfd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4127
-540
lines changed

api/protobuf-spec/github_com_openshift_origin_pkg_build_api_v1.proto

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger-spec/oapi-v1.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23225,6 +23225,14 @@
2322523225
"imageChange": {
2322623226
"$ref": "v1.ImageChangeTrigger",
2322723227
"description": "imageChange contains parameters for an ImageChange type of trigger"
23228+
},
23229+
"gitlab": {
23230+
"$ref": "v1.WebHookTrigger",
23231+
"description": "GitLabWebHook contains the parameters for a GitLab webhook type of trigger"
23232+
},
23233+
"bitbucket": {
23234+
"$ref": "v1.WebHookTrigger",
23235+
"description": "BitbucketWebHook contains the parameters for a Bitbucket webhook type of trigger"
2322823236
}
2322923237
}
2323023238
},
@@ -24137,6 +24145,14 @@
2413724145
"imageChangeBuild": {
2413824146
"$ref": "v1.ImageChangeCause",
2413924147
"description": "imageChangeBuild stores information about an imagechange event that triggered a new build."
24148+
},
24149+
"gitlabWebHook": {
24150+
"$ref": "v1.GitLabWebHookCause",
24151+
"description": "GitLabWebHook represents data for a GitLab webhook that fired a specific build."
24152+
},
24153+
"bitbucketWebHook": {
24154+
"$ref": "v1.BitbucketWebHookCause",
24155+
"description": "BitbucketWebHook represents data for a Bitbucket webhook that fired a specific build."
2414024156
}
2414124157
}
2414224158
},
@@ -24182,6 +24198,34 @@
2418224198
}
2418324199
}
2418424200
},
24201+
"v1.GitLabWebHookCause": {
24202+
"id": "v1.GitLabWebHookCause",
24203+
"description": "GitLabWebHookCause has information about a GitLab webhook that triggered a build.",
24204+
"properties": {
24205+
"revision": {
24206+
"$ref": "v1.SourceRevision",
24207+
"description": "Revision is the git source revision information of the trigger."
24208+
},
24209+
"secret": {
24210+
"type": "string",
24211+
"description": "Secret is the obfuscated webhook secret that triggered a build."
24212+
}
24213+
}
24214+
},
24215+
"v1.BitbucketWebHookCause": {
24216+
"id": "v1.BitbucketWebHookCause",
24217+
"description": "BitbucketWebHookCause has information about a Bitbucket webhook that triggered a build.",
24218+
"properties": {
24219+
"revision": {
24220+
"$ref": "v1.SourceRevision",
24221+
"description": "Revision is the git source revision information of the trigger."
24222+
},
24223+
"secret": {
24224+
"type": "string",
24225+
"description": "Secret is the obfuscated webhook secret that triggered a build."
24226+
}
24227+
}
24228+
},
2418524229
"v1.DockerStrategyOptions": {
2418624230
"id": "v1.DockerStrategyOptions",
2418724231
"description": "DockerStrategyOptions contains extra strategy options for Docker builds",

api/swagger-spec/openshift-openapi-spec.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67844,6 +67844,19 @@
6784467844
}
6784567845
}
6784667846
},
67847+
"v1.BitbucketWebHookCause": {
67848+
"description": "BitbucketWebHookCause has information about a Bitbucket webhook that triggered a build.",
67849+
"properties": {
67850+
"revision": {
67851+
"description": "Revision is the git source revision information of the trigger.",
67852+
"$ref": "#/definitions/v1.SourceRevision"
67853+
},
67854+
"secret": {
67855+
"description": "Secret is the obfuscated webhook secret that triggered a build.",
67856+
"type": "string"
67857+
}
67858+
}
67859+
},
6784767860
"v1.Build": {
6784867861
"description": "Build encapsulates the inputs needed to produce a new deployable image, as well as the status of the execution and a reference to the Pod which executed the build.",
6784967862
"properties": {
@@ -68342,6 +68355,10 @@
6834268355
"v1.BuildTriggerCause": {
6834368356
"description": "BuildTriggerCause holds information about a triggered build. It is used for displaying build trigger data for each build and build configuration in oc describe. It is also used to describe which triggers led to the most recent update in the build configuration.",
6834468357
"properties": {
68358+
"bitbucketWebHook": {
68359+
"description": "BitbucketWebHook represents data for a Bitbucket webhook that fired a specific build.",
68360+
"$ref": "#/definitions/v1.BitbucketWebHookCause"
68361+
},
6834568362
"genericWebHook": {
6834668363
"description": "genericWebHook holds data about a builds generic webhook trigger.",
6834768364
"$ref": "#/definitions/v1.GenericWebHookCause"
@@ -68350,6 +68367,10 @@
6835068367
"description": "gitHubWebHook represents data for a GitHub webhook that fired a specific build.",
6835168368
"$ref": "#/definitions/v1.GitHubWebHookCause"
6835268369
},
68370+
"gitlabWebHook": {
68371+
"description": "GitLabWebHook represents data for a GitLab webhook that fired a specific build.",
68372+
"$ref": "#/definitions/v1.GitLabWebHookCause"
68373+
},
6835368374
"imageChangeBuild": {
6835468375
"description": "imageChangeBuild stores information about an imagechange event that triggered a new build.",
6835568376
"$ref": "#/definitions/v1.ImageChangeCause"
@@ -68366,6 +68387,10 @@
6836668387
"type"
6836768388
],
6836868389
"properties": {
68390+
"bitbucket": {
68391+
"description": "BitbucketWebHook contains the parameters for a Bitbucket webhook type of trigger",
68392+
"$ref": "#/definitions/v1.WebHookTrigger"
68393+
},
6836968394
"generic": {
6837068395
"description": "generic contains the parameters for a Generic webhook type of trigger",
6837168396
"$ref": "#/definitions/v1.WebHookTrigger"
@@ -68374,6 +68399,10 @@
6837468399
"description": "github contains the parameters for a GitHub webhook type of trigger",
6837568400
"$ref": "#/definitions/v1.WebHookTrigger"
6837668401
},
68402+
"gitlab": {
68403+
"description": "GitLabWebHook contains the parameters for a GitLab webhook type of trigger",
68404+
"$ref": "#/definitions/v1.WebHookTrigger"
68405+
},
6837768406
"imageChange": {
6837868407
"description": "imageChange contains parameters for an ImageChange type of trigger",
6837968408
"$ref": "#/definitions/v1.ImageChangeTrigger"
@@ -70637,6 +70666,19 @@
7063770666
}
7063870667
}
7063970668
},
70669+
"v1.GitLabWebHookCause": {
70670+
"description": "GitLabWebHookCause has information about a GitLab webhook that triggered a build.",
70671+
"properties": {
70672+
"revision": {
70673+
"description": "Revision is the git source revision information of the trigger.",
70674+
"$ref": "#/definitions/v1.SourceRevision"
70675+
},
70676+
"secret": {
70677+
"description": "Secret is the obfuscated webhook secret that triggered a build.",
70678+
"type": "string"
70679+
}
70680+
}
70681+
},
7064070682
"v1.GitRepoVolumeSource": {
7064170683
"description": "Represents a volume that is populated with the contents of a git repository. Git repo volumes do not support ownership management. Git repo volumes support SELinux relabeling.",
7064270684
"required": [

contrib/completions/bash/oc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15403,10 +15403,14 @@ _oc_set_triggers()
1540315403
flags_with_completion+=("-f")
1540415404
flags_completion+=("__handle_filename_extension_flag yaml|yml|json")
1540515405
local_nonpersistent_flags+=("--filename=")
15406+
flags+=("--from-bitbucket")
15407+
local_nonpersistent_flags+=("--from-bitbucket")
1540615408
flags+=("--from-config")
1540715409
local_nonpersistent_flags+=("--from-config")
1540815410
flags+=("--from-github")
1540915411
local_nonpersistent_flags+=("--from-github")
15412+
flags+=("--from-gitlab")
15413+
local_nonpersistent_flags+=("--from-gitlab")
1541015414
flags+=("--from-image=")
1541115415
local_nonpersistent_flags+=("--from-image=")
1541215416
flags+=("--from-webhook")

contrib/completions/bash/openshift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20759,10 +20759,14 @@ _openshift_cli_set_triggers()
2075920759
flags_with_completion+=("-f")
2076020760
flags_completion+=("__handle_filename_extension_flag yaml|yml|json")
2076120761
local_nonpersistent_flags+=("--filename=")
20762+
flags+=("--from-bitbucket")
20763+
local_nonpersistent_flags+=("--from-bitbucket")
2076220764
flags+=("--from-config")
2076320765
local_nonpersistent_flags+=("--from-config")
2076420766
flags+=("--from-github")
2076520767
local_nonpersistent_flags+=("--from-github")
20768+
flags+=("--from-gitlab")
20769+
local_nonpersistent_flags+=("--from-gitlab")
2076620770
flags+=("--from-image=")
2076720771
local_nonpersistent_flags+=("--from-image=")
2076820772
flags+=("--from-webhook")

contrib/completions/zsh/oc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15551,10 +15551,14 @@ _oc_set_triggers()
1555115551
flags_with_completion+=("-f")
1555215552
flags_completion+=("__handle_filename_extension_flag yaml|yml|json")
1555315553
local_nonpersistent_flags+=("--filename=")
15554+
flags+=("--from-bitbucket")
15555+
local_nonpersistent_flags+=("--from-bitbucket")
1555415556
flags+=("--from-config")
1555515557
local_nonpersistent_flags+=("--from-config")
1555615558
flags+=("--from-github")
1555715559
local_nonpersistent_flags+=("--from-github")
15560+
flags+=("--from-gitlab")
15561+
local_nonpersistent_flags+=("--from-gitlab")
1555815562
flags+=("--from-image=")
1555915563
local_nonpersistent_flags+=("--from-image=")
1556015564
flags+=("--from-webhook")

contrib/completions/zsh/openshift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20907,10 +20907,14 @@ _openshift_cli_set_triggers()
2090720907
flags_with_completion+=("-f")
2090820908
flags_completion+=("__handle_filename_extension_flag yaml|yml|json")
2090920909
local_nonpersistent_flags+=("--filename=")
20910+
flags+=("--from-bitbucket")
20911+
local_nonpersistent_flags+=("--from-bitbucket")
2091020912
flags+=("--from-config")
2091120913
local_nonpersistent_flags+=("--from-config")
2091220914
flags+=("--from-github")
2091320915
local_nonpersistent_flags+=("--from-github")
20916+
flags+=("--from-gitlab")
20917+
local_nonpersistent_flags+=("--from-gitlab")
2091420918
flags+=("--from-image=")
2091520919
local_nonpersistent_flags+=("--from-image=")
2091620920
flags+=("--from-webhook")

pkg/build/api/types.go

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,13 @@ type CommonSpec struct {
128128
}
129129

130130
const (
131-
BuildTriggerCauseManualMsg = "Manually triggered"
132-
BuildTriggerCauseConfigMsg = "Build configuration change"
133-
BuildTriggerCauseImageMsg = "Image change"
134-
BuildTriggerCauseGithubMsg = "GitHub WebHook"
135-
BuildTriggerCauseGenericMsg = "Generic WebHook"
131+
BuildTriggerCauseManualMsg = "Manually triggered"
132+
BuildTriggerCauseConfigMsg = "Build configuration change"
133+
BuildTriggerCauseImageMsg = "Image change"
134+
BuildTriggerCauseGithubMsg = "GitHub WebHook"
135+
BuildTriggerCauseGenericMsg = "Generic WebHook"
136+
BuildTriggerCauseGitLabMsg = "GitLab WebHook"
137+
BuildTriggerCauseBitbucketMsg = "Bitbucket WebHook"
136138
)
137139

138140
// BuildTriggerCause holds information about a triggered build. It is used for
@@ -155,6 +157,14 @@ type BuildTriggerCause struct {
155157
// ImageChangeBuild stores information about an imagechange event that
156158
// triggered a new build.
157159
ImageChangeBuild *ImageChangeCause
160+
161+
// GitLabWebHook represents data for a GitLab webhook that fired a specific
162+
// build.
163+
GitLabWebHook *GitLabWebHookCause
164+
165+
// BitbucketWebHook represents data for a Bitbucket webhook that fired a
166+
// specific build.
167+
BitbucketWebHook *BitbucketWebHookCause
158168
}
159169

160170
// GenericWebHookCause holds information about a generic WebHook that
@@ -178,6 +188,29 @@ type GitHubWebHookCause struct {
178188
Secret string
179189
}
180190

191+
// CommonWebHookCause factors out the identical format of these webhook
192+
// causes into struct so we can share it in the specific causes; it is too late for
193+
// GitHub and Generic but we can leverage this pattern with GitLab and Bitbucket.
194+
type CommonWebHookCause struct {
195+
// Revision is the git source revision information of the trigger.
196+
Revision *SourceRevision
197+
198+
// Secret is the obfuscated webhook secret that triggered a build.
199+
Secret string
200+
}
201+
202+
// GitLabWebHookCause has information about a GitLab webhook that triggered a
203+
// build.
204+
type GitLabWebHookCause struct {
205+
CommonWebHookCause
206+
}
207+
208+
// BitbucketWebHookCause has information about a Bitbucket webhook that triggered a
209+
// build.
210+
type BitbucketWebHookCause struct {
211+
CommonWebHookCause
212+
}
213+
181214
// ImageChangeCause contains information about the image that triggered a
182215
// build.
183216
type ImageChangeCause struct {
@@ -898,6 +931,13 @@ type BuildTriggerPolicy struct {
898931

899932
// ImageChange contains parameters for an ImageChange type of trigger
900933
ImageChange *ImageChangeTrigger
934+
935+
// GitLabWebHook contains the parameters for a GitLab webhook type of trigger
936+
GitLabWebHook *WebHookTrigger
937+
938+
// BitbucketWebHook contains the parameters for a Bitbucket webhook type of
939+
// trigger
940+
BitbucketWebHook *WebHookTrigger
901941
}
902942

903943
// BuildTriggerType refers to a specific BuildTriggerPolicy implementation.
@@ -909,6 +949,8 @@ var KnownTriggerTypes = sets.NewString(
909949
string(GenericWebHookBuildTriggerType),
910950
string(ImageChangeBuildTriggerType),
911951
string(ConfigChangeBuildTriggerType),
952+
string(GitLabWebHookBuildTriggerType),
953+
string(BitbucketWebHookBuildTriggerType),
912954
)
913955

914956
const (
@@ -922,6 +964,14 @@ const (
922964
GenericWebHookBuildTriggerType BuildTriggerType = "Generic"
923965
GenericWebHookBuildTriggerTypeDeprecated BuildTriggerType = "generic"
924966

967+
// GitLabWebHookBuildTriggerType represents a trigger that launches builds on
968+
// GitLab webhook invocations
969+
GitLabWebHookBuildTriggerType BuildTriggerType = "GitLab"
970+
971+
// BitbucketWebHookBuildTriggerType represents a trigger that launches builds on
972+
// Bitbucket webhook invocations
973+
BitbucketWebHookBuildTriggerType BuildTriggerType = "Bitbucket"
974+
925975
// ImageChangeBuildTriggerType represents a trigger that launches builds on
926976
// availability of a new version of an image
927977
ImageChangeBuildTriggerType BuildTriggerType = "ImageChange"

0 commit comments

Comments
 (0)