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

Don't check LastCommitNotYetBuild on Approve MR action #664

Merged
merged 4 commits into from
Dec 11, 2017

Conversation

jakub-bochenski
Copy link
Contributor

@jakub-bochenski jakub-bochenski commented Nov 14, 2017

Related to #659
I think it makes sense to re-trigger builds on approve even if they were already built.

We have builds that will only do certain actions for approved MRs.
Without this the build would run before the MR was approved and would never execute the approved-only actions.

Nov 14, 2017 4:15:43 PM INFO com.dabsquared.gitlabjenkins.trigger.handler.merge.MergeRequestHookTriggerHandlerImpl isLastCommitNotYetBuild

Last commit in Merge Request has already been built in build #119

@jakub-bochenski
Copy link
Contributor Author

@omehegan can you let me know if this change is going in the right direction?
I don't like how complex the condition is now, but I don't see any better way to achieve that

@jakub-bochenski
Copy link
Contributor Author

Another approach would be to add a separate option "Approved Merge Request Events" like the "Opened Merge Request Events" and "Accepted Merge Request Events".

However this would require a change to the flow described above to split off the approved-only part into a separate job.

@omehegan
Copy link
Member

@jakub-bochenski This seems like a good improvement. Out of curiosity, what are you checking in your logic about whether the MR is approved? The gitlabActionType variable? Have you already tested this change?

@mreichel or @Argelbargel do you have any comments on this? The actual diff is small, but @jakub-bochenski is right that the conditional statement here is pretty complex. I don't know if it can be simplified or if it would be worth trying.

@Argelbargel
Copy link
Contributor

This change would be a good addition to make it possible to e.g. create release-builds after approval or something similar. i think there should be an option to disable building on/after approval for those use-cases where you just want to check whether everything is okay before approving a merge-request.

As for the conditions compexity: the additional check does not make it that worse - for a start i would refactor the checks into their own method (shouldBuild() or something) and leave it at that...

@jakub-bochenski
Copy link
Contributor Author

jakub-bochenski commented Nov 15, 2017

Out of curiosity, what are you checking in your logic about whether the MR is approved? The gitlabActionType variable?

@omehegan actually I haven't thought of that. What we do now is we only grab the MR id from environment variable and then use Gitlab API for everything else. This makes testing outside of Jenkins easier. Your approach has the advantage of being faster and more atomic.

PS. The value of gitlabActionType is still only MERGE so that wouldn't work

@jakub-bochenski
Copy link
Contributor Author

Have you already tested this change?

I tested it today and it's broken :( I'm seeing the hook is received in the log, but then nothing not even the "Last commit in Merge Request has already been built in build".

I will investigate this tomorrow

Nov 15, 2017 5:37:25 PM INFO com.dabsquared.gitlabjenkins.webhook.GitLabWebHook getDynamic
WebHook called with url: /project/gitla-labels-test

Nov 15, 2017 5:37:25 PM FINE com.dabsquared.gitlabjenkins.webhook.build.MergeRequestBuildAction 
MergeRequest: {

@jakub-bochenski jakub-bochenski force-pushed the patch-2 branch 2 times, most recently from 3550dde to 03c7fa8 Compare November 20, 2017 11:48
@jakub-bochenski
Copy link
Contributor Author

@omehegan this works after all: turns out we had a secret mismatch between the job config and gitlab trigger

Nov 20, 2017 1:00:33 PM INFO com.dabsquared.gitlabjenkins.trigger.handler.AbstractWebHookTriggerHandler handle

gitla-labels-test triggered for merge request.

@jakub-bochenski
Copy link
Contributor Author

I think I will rewrite this to have a separate trigger option like it was done in #508

@jakub-bochenski
Copy link
Contributor Author

Tested manually, with this settings MRs will trigger only on MR approve (and not e.g. on push to source branch)
screenshot_20171120_212555

Will add automated test coverage tomorrow

@jakub-bochenski jakub-bochenski force-pushed the patch-2 branch 4 times, most recently from efe2bf5 to ed47391 Compare November 21, 2017 12:46
@jakub-bochenski
Copy link
Contributor Author

@omehegan I'm done, can you please review?

Can you please also check #671 - it makes doing any changes very cumbersome

@omehegan
Copy link
Member

@jakub-bochenski can you resolve merge conflicts? Then ping @Argelbargel or @mreichel for review, I unfortunately won't have much time for the plugin for the next couple of weeks.

@jakub-bochenski
Copy link
Contributor Author

@Argelbargel or @mreichel please review

@Argelbargel
Copy link
Contributor

@jakub-bochenski: do your changes cause the test-failures or is this "just" a flickering test?

@jakub-bochenski
Copy link
Contributor Author

jakub-bochenski commented Nov 23, 2017

@Argelbargel looks random
I didn't touch this part and 1aadd46 was green

Actually master is red since f8c9cbd

@mreichel
Copy link
Contributor

It is red since f8c9cbd because of failing dependency check (@Argelbargel shouldn't we get rid of the dependency check? It does not work properly and confuses everyone). The tests fail since 4d50561, I will look into it.

@Argelbargel
Copy link
Contributor

@mreichel: do you mean the check running when pushing to a pr? yes please!

@jakub-bochenski
Copy link
Contributor Author

@Argelbargel the build is now green, can I get a review please?

@Argelbargel Argelbargel self-assigned this Nov 27, 2017
@jakub-bochenski
Copy link
Contributor Author

Last build failed because of some problems with Jenkins Azure host java.nio.channels.ClosedChannelException

Copy link
Contributor

@Argelbargel Argelbargel left a comment

Choose a reason for hiding this comment

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

I think the changes are okay

@jakub-bochenski
Copy link
Contributor Author

@Argelbargel or @mreichel can you merge this?

@Argelbargel Argelbargel merged commit 316b8be into jenkinsci:master Dec 11, 2017
@jakub-bochenski jakub-bochenski deleted the patch-2 branch March 3, 2018 01:23
exceed-alae pushed a commit to exceed-alae/gitlab-plugin that referenced this pull request May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants