Skip to content

support for gitlab and bitbucket webhooks #13389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions api/swagger-spec/oapi-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -23225,6 +23225,14 @@
"imageChange": {
"$ref": "v1.ImageChangeTrigger",
"description": "imageChange contains parameters for an ImageChange type of trigger"
},
"gitlab": {
"$ref": "v1.WebHookTrigger",
"description": "GitLabWebHook contains the parameters for a GitLab webhook type of trigger"
},
"bitbucket": {
"$ref": "v1.WebHookTrigger",
"description": "BitbucketWebHook contains the parameters for a Bitbucket webhook type of trigger"
}
}
},
Expand Down Expand Up @@ -24137,6 +24145,14 @@
"imageChangeBuild": {
"$ref": "v1.ImageChangeCause",
"description": "imageChangeBuild stores information about an imagechange event that triggered a new build."
},
"gitlabWebHook": {
"$ref": "v1.GitLabWebHookCause",
"description": "GitLabWebHook represents data for a GitLab webhook that fired a specific build."
},
"bitbucketWebHook": {
"$ref": "v1.BitbucketWebHookCause",
"description": "BitbucketWebHook represents data for a Bitbucket webhook that fired a specific build."
}
}
},
Expand Down Expand Up @@ -24182,6 +24198,34 @@
}
}
},
"v1.GitLabWebHookCause": {
"id": "v1.GitLabWebHookCause",
"description": "GitLabWebHookCause has information about a GitLab webhook that triggered a build.",
"properties": {
"revision": {
"$ref": "v1.SourceRevision",
"description": "Revision is the git source revision information of the trigger."
},
"secret": {
"type": "string",
"description": "Secret is the obfuscated webhook secret that triggered a build."
}
}
},
"v1.BitbucketWebHookCause": {
"id": "v1.BitbucketWebHookCause",
"description": "BitbucketWebHookCause has information about a Bitbucket webhook that triggered a build.",
"properties": {
"revision": {
"$ref": "v1.SourceRevision",
"description": "Revision is the git source revision information of the trigger."
},
"secret": {
"type": "string",
"description": "Secret is the obfuscated webhook secret that triggered a build."
}
}
},
"v1.DockerStrategyOptions": {
"id": "v1.DockerStrategyOptions",
"description": "DockerStrategyOptions contains extra strategy options for Docker builds",
Expand Down
42 changes: 42 additions & 0 deletions api/swagger-spec/openshift-openapi-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -67844,6 +67844,19 @@
}
}
},
"v1.BitbucketWebHookCause": {
"description": "BitbucketWebHookCause has information about a Bitbucket webhook that triggered a build.",
"properties": {
"revision": {
"description": "Revision is the git source revision information of the trigger.",
"$ref": "#/definitions/v1.SourceRevision"
},
"secret": {
"description": "Secret is the obfuscated webhook secret that triggered a build.",
"type": "string"
}
}
},
"v1.Build": {
"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.",
"properties": {
Expand Down Expand Up @@ -68342,6 +68355,10 @@
"v1.BuildTriggerCause": {
"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.",
"properties": {
"bitbucketWebHook": {
"description": "BitbucketWebHook represents data for a Bitbucket webhook that fired a specific build.",
"$ref": "#/definitions/v1.BitbucketWebHookCause"
},
"genericWebHook": {
"description": "genericWebHook holds data about a builds generic webhook trigger.",
"$ref": "#/definitions/v1.GenericWebHookCause"
Expand All @@ -68350,6 +68367,10 @@
"description": "gitHubWebHook represents data for a GitHub webhook that fired a specific build.",
"$ref": "#/definitions/v1.GitHubWebHookCause"
},
"gitlabWebHook": {
"description": "GitLabWebHook represents data for a GitLab webhook that fired a specific build.",
"$ref": "#/definitions/v1.GitLabWebHookCause"
},
"imageChangeBuild": {
"description": "imageChangeBuild stores information about an imagechange event that triggered a new build.",
"$ref": "#/definitions/v1.ImageChangeCause"
Expand All @@ -68366,6 +68387,10 @@
"type"
],
"properties": {
"bitbucket": {
"description": "BitbucketWebHook contains the parameters for a Bitbucket webhook type of trigger",
"$ref": "#/definitions/v1.WebHookTrigger"
},
"generic": {
"description": "generic contains the parameters for a Generic webhook type of trigger",
"$ref": "#/definitions/v1.WebHookTrigger"
Expand All @@ -68374,6 +68399,10 @@
"description": "github contains the parameters for a GitHub webhook type of trigger",
"$ref": "#/definitions/v1.WebHookTrigger"
},
"gitlab": {
"description": "GitLabWebHook contains the parameters for a GitLab webhook type of trigger",
"$ref": "#/definitions/v1.WebHookTrigger"
},
"imageChange": {
"description": "imageChange contains parameters for an ImageChange type of trigger",
"$ref": "#/definitions/v1.ImageChangeTrigger"
Expand Down Expand Up @@ -70637,6 +70666,19 @@
}
}
},
"v1.GitLabWebHookCause": {
"description": "GitLabWebHookCause has information about a GitLab webhook that triggered a build.",
"properties": {
"revision": {
"description": "Revision is the git source revision information of the trigger.",
"$ref": "#/definitions/v1.SourceRevision"
},
"secret": {
"description": "Secret is the obfuscated webhook secret that triggered a build.",
"type": "string"
}
}
},
"v1.GitRepoVolumeSource": {
"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.",
"required": [
Expand Down
4 changes: 4 additions & 0 deletions contrib/completions/bash/oc
Original file line number Diff line number Diff line change
Expand Up @@ -15403,10 +15403,14 @@ _oc_set_triggers()
flags_with_completion+=("-f")
flags_completion+=("__handle_filename_extension_flag yaml|yml|json")
local_nonpersistent_flags+=("--filename=")
flags+=("--from-bitbucket")
local_nonpersistent_flags+=("--from-bitbucket")
flags+=("--from-config")
local_nonpersistent_flags+=("--from-config")
flags+=("--from-github")
local_nonpersistent_flags+=("--from-github")
flags+=("--from-gitlab")
local_nonpersistent_flags+=("--from-gitlab")
flags+=("--from-image=")
local_nonpersistent_flags+=("--from-image=")
flags+=("--from-webhook")
Expand Down
4 changes: 4 additions & 0 deletions contrib/completions/bash/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -20759,10 +20759,14 @@ _openshift_cli_set_triggers()
flags_with_completion+=("-f")
flags_completion+=("__handle_filename_extension_flag yaml|yml|json")
local_nonpersistent_flags+=("--filename=")
flags+=("--from-bitbucket")
local_nonpersistent_flags+=("--from-bitbucket")
flags+=("--from-config")
local_nonpersistent_flags+=("--from-config")
flags+=("--from-github")
local_nonpersistent_flags+=("--from-github")
flags+=("--from-gitlab")
local_nonpersistent_flags+=("--from-gitlab")
flags+=("--from-image=")
local_nonpersistent_flags+=("--from-image=")
flags+=("--from-webhook")
Expand Down
4 changes: 4 additions & 0 deletions contrib/completions/zsh/oc
Original file line number Diff line number Diff line change
Expand Up @@ -15551,10 +15551,14 @@ _oc_set_triggers()
flags_with_completion+=("-f")
flags_completion+=("__handle_filename_extension_flag yaml|yml|json")
local_nonpersistent_flags+=("--filename=")
flags+=("--from-bitbucket")
local_nonpersistent_flags+=("--from-bitbucket")
flags+=("--from-config")
local_nonpersistent_flags+=("--from-config")
flags+=("--from-github")
local_nonpersistent_flags+=("--from-github")
flags+=("--from-gitlab")
local_nonpersistent_flags+=("--from-gitlab")
flags+=("--from-image=")
local_nonpersistent_flags+=("--from-image=")
flags+=("--from-webhook")
Expand Down
4 changes: 4 additions & 0 deletions contrib/completions/zsh/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -20907,10 +20907,14 @@ _openshift_cli_set_triggers()
flags_with_completion+=("-f")
flags_completion+=("__handle_filename_extension_flag yaml|yml|json")
local_nonpersistent_flags+=("--filename=")
flags+=("--from-bitbucket")
local_nonpersistent_flags+=("--from-bitbucket")
flags+=("--from-config")
local_nonpersistent_flags+=("--from-config")
flags+=("--from-github")
local_nonpersistent_flags+=("--from-github")
flags+=("--from-gitlab")
local_nonpersistent_flags+=("--from-gitlab")
flags+=("--from-image=")
local_nonpersistent_flags+=("--from-image=")
flags+=("--from-webhook")
Expand Down
60 changes: 55 additions & 5 deletions pkg/build/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,13 @@ type CommonSpec struct {
}

const (
BuildTriggerCauseManualMsg = "Manually triggered"
BuildTriggerCauseConfigMsg = "Build configuration change"
BuildTriggerCauseImageMsg = "Image change"
BuildTriggerCauseGithubMsg = "GitHub WebHook"
BuildTriggerCauseGenericMsg = "Generic WebHook"
BuildTriggerCauseManualMsg = "Manually triggered"
BuildTriggerCauseConfigMsg = "Build configuration change"
BuildTriggerCauseImageMsg = "Image change"
BuildTriggerCauseGithubMsg = "GitHub WebHook"
BuildTriggerCauseGenericMsg = "Generic WebHook"
BuildTriggerCauseGitLabMsg = "GitLab WebHook"
BuildTriggerCauseBitbucketMsg = "Bitbucket WebHook"
)

// BuildTriggerCause holds information about a triggered build. It is used for
Expand All @@ -155,6 +157,14 @@ type BuildTriggerCause struct {
// ImageChangeBuild stores information about an imagechange event that
// triggered a new build.
ImageChangeBuild *ImageChangeCause

// GitLabWebHook represents data for a GitLab webhook that fired a specific
// build.
GitLabWebHook *GitLabWebHookCause

// BitbucketWebHook represents data for a Bitbucket webhook that fired a
// specific build.
BitbucketWebHook *BitbucketWebHookCause
}

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

// CommonWebHookCause factors out the identical format of these webhook
// causes into struct so we can share it in the specific causes; it is too late for
// GitHub and Generic but we can leverage this pattern with GitLab and Bitbucket.
type CommonWebHookCause struct {
// Revision is the git source revision information of the trigger.
Revision *SourceRevision

// Secret is the obfuscated webhook secret that triggered a build.
Secret string
}

// GitLabWebHookCause has information about a GitLab webhook that triggered a
// build.
type GitLabWebHookCause struct {
CommonWebHookCause
}

// BitbucketWebHookCause has information about a Bitbucket webhook that triggered a
// build.
type BitbucketWebHookCause struct {
CommonWebHookCause
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need 4 identical structs (in fact we shouldn't have had 2 identical structs in the first place). I don't think we can fix the 2 we have, but it would seem logical to factor these out and use an embedded field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update pushed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bparees out of interest, what is it that prevents fixing the 2 existing structs to CommonWebHookCause?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jim-minter it would change the protobuf format which would break backwards compatibility.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have we shipped protobuf yet? we have at least one field we need to fix up

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CommonWebHookCause is ok for containing shared fields, but we don't want to lose the ability to have a field specific to a particular webhook type, so we would nest the common struct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah +1 on wanting to retain a unique top level struct for each webhook type, even if for now they all just embed a single common struct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed - so is that agreement that the change can & should be made?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the discussion we're having :) need @smarterclayton to tell us if we're still ok to change the protobuf or not. If we are, then yes we want to refactor all the webhookcause structs to use a single common struct field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on a side conversation I had with @bparees yesterday, changing GitHubWebHookCause and GenericWebHookCause to leverage CommonWebHookCause is still dependent @smarterclayton confirming to him where to land on the protobuf / etcd / storage concern. And that is the only change still on the table.


// ImageChangeCause contains information about the image that triggered a
// build.
type ImageChangeCause struct {
Expand Down Expand Up @@ -898,6 +931,13 @@ type BuildTriggerPolicy struct {

// ImageChange contains parameters for an ImageChange type of trigger
ImageChange *ImageChangeTrigger

// GitLabWebHook contains the parameters for a GitLab webhook type of trigger
GitLabWebHook *WebHookTrigger

// BitbucketWebHook contains the parameters for a Bitbucket webhook type of
// trigger
BitbucketWebHook *WebHookTrigger
}

// BuildTriggerType refers to a specific BuildTriggerPolicy implementation.
Expand All @@ -909,6 +949,8 @@ var KnownTriggerTypes = sets.NewString(
string(GenericWebHookBuildTriggerType),
string(ImageChangeBuildTriggerType),
string(ConfigChangeBuildTriggerType),
string(GitLabWebHookBuildTriggerType),
string(BitbucketWebHookBuildTriggerType),
)

const (
Expand All @@ -922,6 +964,14 @@ const (
GenericWebHookBuildTriggerType BuildTriggerType = "Generic"
GenericWebHookBuildTriggerTypeDeprecated BuildTriggerType = "generic"

// GitLabWebHookBuildTriggerType represents a trigger that launches builds on
// GitLab webhook invocations
GitLabWebHookBuildTriggerType BuildTriggerType = "GitLab"

// BitbucketWebHookBuildTriggerType represents a trigger that launches builds on
// Bitbucket webhook invocations
BitbucketWebHookBuildTriggerType BuildTriggerType = "Bitbucket"

// ImageChangeBuildTriggerType represents a trigger that launches builds on
// availability of a new version of an image
ImageChangeBuildTriggerType BuildTriggerType = "ImageChange"
Expand Down
Loading