Skip to content
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

support for gitlab and bitbucket webhooks #13389

Merged
merged 1 commit into from
Apr 3, 2017

Conversation

gabemontero
Copy link
Contributor

@openshift/devex PTAL

per the discussion during sprint planning, we did not updatea the --from-webhook, etc. options with oc start-build, nor did we change oc new-app to either automatically add the triggers for gitlab and webhook or add yet another option to oc new-app to let the user choose to automatically add the triggers.

Of course we can further debate those points along with the content of the code changes as everyone sees fit.

BuildTriggerCauseGithubMsg = "GitHub WebHook"
BuildTriggerCauseGenericMsg = "Generic WebHook"
BuildTriggerCauseGitlabMsg = "Gitlab WebHook"
BuildTriggerCauseBitBucketMsg = "BitBucket WebHook"
Copy link
Member

@coreydaley coreydaley Mar 15, 2017

Choose a reason for hiding this comment

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

Just a nit, it's Bitbucket not BitBucket (also other places in the pr)

BuildTriggerCauseImageMsg = "Image change"
BuildTriggerCauseGithubMsg = "GitHub WebHook"
BuildTriggerCauseGenericMsg = "Generic WebHook"
BuildTriggerCauseGitlabMsg = "Gitlab WebHook"
Copy link
Member

@coreydaley coreydaley Mar 15, 2017

Choose a reason for hiding this comment

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

nit: should be GitLab (consistent with other places in the PR)


// GitLabWebHook represents data for a GitLab webhook that fired a specific
// build.
GitLabWebHook *GitLabWebHookCause `protobuf:"bytes,5,opt,name=gitLabWebHook"`
Copy link
Member

Choose a reason for hiding this comment

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

missing json section


// BitBucketWebHook represents data for a BitBucket webhook that fired a
// specific build.
BitBucketWebHook *BitBucketWebHookCause `protobuf:"bytes,6,opt,name=bitBucketWebHook"`
Copy link
Member

Choose a reason for hiding this comment

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

missing json section

// build.
type GitLabWebHookCause struct {
// Revision is the git source revision information of the trigger.
Revision *SourceRevision `protobuf:"bytes,1,opt,name=revision"`
Copy link
Member

Choose a reason for hiding this comment

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

missing json section

Revision *SourceRevision `protobuf:"bytes,1,opt,name=revision"`

// Secret is the obfuscated webhook secret that triggered a build.
Secret string `protobuf:"bytes,2,opt,name=secret"`
Copy link
Member

Choose a reason for hiding this comment

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

missing json section

// build.
type BitBucketWebHookCause struct {
// Revision is the git source revision information of the trigger.
Revision *SourceRevision `protobuf:"bytes,1,opt,name=revision"`
Copy link
Member

Choose a reason for hiding this comment

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

missing json section

Revision *SourceRevision `protobuf:"bytes,1,opt,name=revision"`

// Secret is the obfuscated webhook secret that triggered a build.
Secret string `protobuf:"bytes,2,opt,name=secret"`
Copy link
Member

Choose a reason for hiding this comment

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

missing json section

@@ -780,6 +808,13 @@ type BuildTriggerPolicy struct {

// imageChange contains parameters for an ImageChange type of trigger
ImageChange *ImageChangeTrigger `json:"imageChange,omitempty" protobuf:"bytes,4,opt,name=imageChange"`

// GitLabWebHook contains the parameters for a GitLab webhook type of trigger
GitLabWebHook *WebHookTrigger `protobuf:"bytes,5,opt,name=gitLabWebHook"`
Copy link
Member

Choose a reason for hiding this comment

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

missing json section


// BitBucketWebHook contains the parameters for a BitBucket webhook type of
// trigger
BitBucketWebHook *WebHookTrigger `protobuf:"bytes,6,opt,name=bitBucketWebHook"`
Copy link
Member

Choose a reason for hiding this comment

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

missing json section

Name string `json:"name"`
}

// Extract services webhooks from github.com
Copy link
Member

Choose a reason for hiding this comment

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

should be bitbucket

}

// NOTE - unlike github, the head commit is not highlighted ... only the commit array is provided,
// where it the last commit is the latest commit
Copy link
Member

Choose a reason for hiding this comment

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

grammar

Commits []commit `json:"commits,omitempty"`
}

// Extract services webhooks from github.com
Copy link
Member

Choose a reason for hiding this comment

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

should be gitlab

CommonSpec: api.CommonSpec{
Source: api.BuildSource{
Git: &api.GitBuildSource{
URI: "git://github.com/my/repo.git",
Copy link
Member

Choose a reason for hiding this comment

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

should be gitlab.com?

Choose a reason for hiding this comment

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

I think this can be any URI? I think the intended use is a custom gitlab server.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good

Copy link
Contributor

Choose a reason for hiding this comment

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

if you want to make it clearer you can make it git://someurl.com/my/repo.git

CommonSpec: api.CommonSpec{
Source: api.BuildSource{
Git: &api.GitBuildSource{
URI: "git://github.com/my/repo.git",
Copy link
Member

Choose a reason for hiding this comment

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

should be gitlab.com?

Choose a reason for hiding this comment

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

I think this can be any URI? I think the intended use is a custom gitlab server.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good

@@ -61,6 +61,7 @@ func FindTriggerPolicy(triggerType buildapi.BuildTriggerType, config *buildapi.B
// defined webhook secrets and if it is valid, returns its information.
func ValidateWebHookSecret(webHookTriggers []buildapi.BuildTriggerPolicy, secret string) (*buildapi.WebHookTrigger, error) {
for _, trigger := range webHookTriggers {
//TODO Could we switch this to a switch?
Copy link
Member

Choose a reason for hiding this comment

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

agree, might be cleaner as a switch

@@ -327,6 +327,42 @@ func mockBuildConfigImageParms(imageName, imageStream, imageTag string) *buildap
Secret: "secret102",
},
},
{
Type: buildapi.GitLabWebHookBuildTriggerType,
GitLabWebHook: &buildapi.WebHookTrigger{
Copy link
Member

Choose a reason for hiding this comment

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

maybe change the name of this file if it is going to include gitlab and bitbucket tests also?

Choose a reason for hiding this comment

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

I definitely agree. In another PR, I had to make a webhookgeneric_test, which doesn't look good. On it.

@gabemontero
Copy link
Contributor Author

fyi @oatmealraisin is taking on the first set of comments here from @coreydaley ... he'll push / squash when complete

@smarterclayton
Copy link
Contributor

Did you update set triggers?

@gabemontero
Copy link
Contributor Author

gabemontero commented Mar 15, 2017 via email

@smarterclayton
Copy link
Contributor

smarterclayton commented Mar 15, 2017 via email

@gabemontero
Copy link
Contributor Author

gabemontero commented Mar 15, 2017 via email

@oatmealraisin
Copy link

@coreydaley Thanks for the review! I've updated the PR based on your comments.

@@ -126,6 +162,40 @@ func TestFindTriggerPolicyMatchedGithubWebHook(t *testing.T) {
}
}

func TestFindTriggerPolicyMatchedGitlabWebHook(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

GitLab


func TestInstantiateBuildTriggerCauseGitLabWebHook(t *testing.T) {
buildTriggerCauses := []buildapi.BuildTriggerCause{}
changeMessage := buildapi.BuildTriggerCauseGitlabMsg
Copy link
Member

Choose a reason for hiding this comment

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

GitLab

if cause.GitLabWebHook.Secret != hiddenSecret {
t.Errorf("Expected obfuscated secret to be: %s", hiddenSecret)
}
if cause.Message != api.BuildTriggerCauseGitlabMsg {
Copy link
Member

Choose a reason for hiding this comment

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

GitLab


// GitLabWebHook represents data for a GitLab webhook that fired a specific
// build.
GitLabWebHook *GitLabWebHookCause `json:"gitLabWebHook, omitempty" protobuf:"bytes,5,opt,name=gitLabWebHook"`
Copy link
Member

Choose a reason for hiding this comment

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

remove space after comma


// BitbucketWebHook represents data for a Bitbucket webhook that fired a
// specific build.
BitbucketWebHook *BitbucketWebHookCause `json:"bitbucketWebhook, omitempty" protobuf:"bytes,6,opt,name=bitbucketWebHook"`
Copy link
Member

@coreydaley coreydaley Mar 15, 2017

Choose a reason for hiding this comment

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

remove space after comma, upcase H on hook

@gabemontero
Copy link
Contributor Author

gabemontero commented Mar 15, 2017

@smarterclayton @csrwng - I was talking with @bparees a bit about the oc set triggers specifics and we circled back to the "should oc new-app automatically add gitlab and bitbucket triggers" like they do with github and generic question.

Per the details I put in the PR's description, I think we had left sprint planning with a decision of not adding them, but even if I am mis-remembering, in any event, both @bparees and I are still on the fence.

What is y'all's respective takes? Note - earlier @smarterclayton said he was fine with us not updating new-app ... but that does not necessarily imply not being OK with updating new-app

@oatmealraisin
Copy link

@coreydaley Added your requests!


// BitbucketWebHook represents data for a Bitbucket webhook that fired a
// specific build.
BitbucketWebHook *BitbucketWebHookCause `json:"bitbucketWebhook,omitempty" protobuf:"bytes,6,opt,name=bitbucketWebHook"`
Copy link
Member

Choose a reason for hiding this comment

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

consistency: capitalize the h in Webhook

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@smarterclayton
Copy link
Contributor

I'm still ok not adding them automatically. They increase object size significantly. And they're just not used that often.

@gabemontero
Copy link
Contributor Author

OK I've pushed the trigger changes for gitlab/bitbucket ... per @smarterclayton we are NOT automatically adding gitlab / bitbucket on new-app

@gabemontero
Copy link
Contributor Author

Yeah, the wait for a build stuff is the mystery. Some tracing there would have helped, but perhaps tracing would be too chatty in the normal case ??

In fact, of you look at the build log dump after the build describe, it appears that the build completed successfully, including the push:

2017-03-22T19:16:01.775294000Z Successfully built 56fe6837c429
2017-03-22T19:16:01.784125000Z Pushing image 172.30.98.5:5000/extended-test-docker-build-pullsecret-z64pc-vv229/image1:latest ...
2017-03-22T19:16:02.504076000Z Pushed 0/1 layers, 3% complete
2017-03-22T19:16:35.356651000Z Pushed 1/1 layers, 100% complete
2017-03-22T19:16:36.106002000Z Push successful

Certainly seems more test framework than code base ... going to try and test again.

[test]

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 22, 2017
@gabemontero
Copy link
Contributor Author

I'll push the necessary rebase updates shortly

@gabemontero
Copy link
Contributor Author

OK post-rebase the test just passed again, and a second one is now running (perhaps the extra test comment I posted yesterday)

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 23, 2017
@gabemontero
Copy link
Contributor Author

the second test hit 2 known flakes ... flake #13067 and flake #12072

other than that everything passed (and the prior test passed completely)

with the api approval (thanks @liggitt ) a question to @bparees - assuming we can debug the start build and wait issue in a separate pull (I can boot that up today) and that it seens ext test infrastructure related since the build actually succeeded, and the latest failures being known flakes, with a successful test run sandwiched in between, is this in "ygtm" state, and we should start the fork ami process?

@bparees
Copy link
Contributor

bparees commented Mar 23, 2017

a question to @bparees - assuming we can debug the start build and wait issue in a separate pull (I can boot that up today) and that it seens ext test infrastructure related since the build actually succeeded, and the latest failures being known flakes, with a successful test run sandwiched in between, is this in "ygtm" state, and we should start the fork ami process?

yup.

@gabemontero
Copy link
Contributor Author

cool - thx @bparees

@gabemontero gabemontero force-pushed the new-webhooks branch 2 times, most recently from 7ca43e3 to f71456f Compare March 24, 2017 13:15
@gabemontero
Copy link
Contributor Author

gabemontero commented Mar 24, 2017

going to add some temporary debug in hack/build-base-images.sh via a separate commit to this branch to debug the issue creating fork ami's ... i'll revert the debug commit when things are sorted out.

I previously checked out this pr's branch in an aws instance I spun up yesterday and ran the vagrant build-base-images command successfully.

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 9d300e8

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/475/) (Base Commit: 959be87)

@bparees
Copy link
Contributor

bparees commented Apr 3, 2017

merging as is. We will revisit refactoring the existing webhookcause structs to use the new common embedded struct once @smarterclayton is back/weighs in on the protobuf implications.

[merge]

@gabemontero
Copy link
Contributor Author

gabemontero commented Apr 3, 2017

The merge jobs are still cooking, but we already have the conformance install setup hitting something that looks similar to flake #13594

@bparees
Copy link
Contributor

bparees commented Apr 3, 2017

flake #13606 though i'm not convinced it's a flake vs broken.

[merge]

@gabemontero
Copy link
Contributor Author

@gabemontero
Copy link
Contributor Author

Seems like a long shot, but just in case, any chance rebasing this PR to the latest origin would help things?

@bparees
Copy link
Contributor

bparees commented Apr 3, 2017 via email

@bparees
Copy link
Contributor

bparees commented Apr 3, 2017

Seems like a long shot, but just in case, any chance rebasing this PR to the latest origin would help things?

rebasing will never affect the results of a test/merge, PRs are always tested/merged by applying the PR changes onto the latest master code (which is the same thing a rebase would do).

@stevekuznetsov thinks he's fixed the issue these PRs were hitting, hopefully the merge will go through now.

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 9d300e8

@openshift-bot
Copy link
Contributor

openshift-bot commented Apr 3, 2017

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/237/) (Base Commit: 8b6ea7f) (Image: devenv-rhel7_6114)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants