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

Add support for BitBucket Pull Requests #319

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rayvincent2
Copy link

@rayvincent2 rayvincent2 commented Apr 30, 2023

PR Details

Add support for Bitbucket Pull Requests

Description

In order to properly retrieve Jenkins pipeline and template files in a repository, we must perform special detection and handling of BitBucket PRs. Since the SCMHead retrieved from a PR Jenkins branch doesn't have the correct information to create an SCMFileSystem, we must detect if the SCMHead is of type com.cloudbees.jenkins.plugins.bitbucket.PullRequestSCMHead and then create a custom SCMHead of type com.cloudbees.jenkins.plugins.bitbucket.BranchSCMHead which points to the HEAD of the PRs source branch. This allows us to create a SCMFileSystem that will allow us to retrieve the Jenkins pipeline_config.groovy and Jenkinsfile.

This PR fixes #308.

How Has This Been Tested

JTE was inoperable against BitBucket Server 7. After manually building the .hpi from this commit, we installed it and were able to confirm it working without issue.

Testing Environment:

  • Jenkins 2.346.1
  • BitBucket Server 7

Types of Changes

  • Added Unit Testing
  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have added the appropriate label for this PR
  • If necessary, I have updated the documentation accordingly.
  • All new and existing tests passed.

@steven-terrana-bah
Copy link

thank you! I'll review as soon as i'm able.

@rayvincent2
Copy link
Author

The flaw that this PR has is that it only generates the SCMFileSystem from the PR's source branch and doesn't perform any kind of merge. It suits our needs as we always rebase all our PRs against the target branch. But I can see this may not be a solution that suits all cases. It may still need a little work.

@steven-terrana
Copy link

Thanks @rayvincent2 - another issue is that this now places a required dependency on the Bitbucket Branch Source plugin.

It would be preferable to use the patterns described in the linked documentation to make this an Optional Dependency

@rayvincent2
Copy link
Author

Very good! Thanks for catching that and handing me the perfect resource to take it the extra step. Now I just need to carve out time to make that tweak. I'm a bit busy now, but will get around to it.

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.

[Bug]: Bitbucket multibranch tag build doesn't load pipeline_config.groovy on the repository
3 participants