Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

Allow to specify git branch instead of pull request id, Allow to break the build#93

Closed
ghenzler wants to merge 1 commit intoAmadeusITGroup:masterfrom
ghenzler:feature/#91-#92-automatic-PR-id-from-branch-and-fail-build
Closed

Allow to specify git branch instead of pull request id, Allow to break the build#93
ghenzler wants to merge 1 commit intoAmadeusITGroup:masterfrom
ghenzler:feature/#91-#92-automatic-PR-id-from-branch-and-fail-build

Conversation

@ghenzler
Copy link

@ghenzler ghenzler commented Dec 1, 2016

#91 Allow to break the build if there are issues that need attention
#92 Allow to specify git branch instead of pull request id
Also includes existing PRs for #22 and #19

…eed attention

AmadeusITGroup#92 Allow to specify git branch instead of pull request id
Also includes existing PRs for AmadeusITGroup#22 and AmadeusITGroup#19
public String getStashPullRequestId() throws StashConfigurationException {
String result = config.getPullRequestId();

if(StringUtils.isNotBlank(config.getPullRequestBranch())) {
Copy link
Author

Choose a reason for hiding this comment

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

This is the main part for #92 - doing this in StashIssueReportingPostJob directly was not that easy (obscure junit test failures) but it would probably cleaner to move it there.

LOGGER.error("Something unexpected went wrong: {}", e.getMessage(), e);
}

failBuildIfNecessary(project, issueReport);
Copy link
Author

Choose a reason for hiding this comment

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

Main part for #91 - needs to be outside of try... catch since the fail build should even work, if there is no pull request (yet)

Long size = (Long) response.get("size");
if(size==0) {
throw new GitBranchNotFoundOrNotUniqueException("Found no PR for branch "+branchName + " in repo "+repository);
} else if(size==1) {
Copy link

@jannylund jannylund Dec 20, 2016

Choose a reason for hiding this comment

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

What if you run a git-flow branching scheme and make a hotfix commit with PR towards both develop and master (if they happen to be in sync). That case would likely trigger size == 2 and still be valid, right?

@tknerr
Copy link

tknerr commented Apr 3, 2017

+1 for this. we also do have feature branch builds where we don't know what the corresponding PR id is

@t-8ch
Copy link
Contributor

t-8ch commented Apr 3, 2017

@tknerr Please see the discussion in #92 for the reasons this will probably not be implemented.

@tknerr
Copy link

tknerr commented Apr 6, 2017

Thanks @t-8ch for the pointer. So I agree, in order to get predictable behaviour and find max 1 PR you would need to specify both source and target branch.

I still think that would be useful if implemented that way. Alas, I'm also waiting for jenkinsci/bitbucket-branch-source-plugin#25 and once this will be merged we can probably start using PR builds (vs feature branch builds), in which case we would have the PR ID available again

@t-8ch t-8ch closed this Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants