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
[JENKINS-47254] Support for building tags for Bitbucket Server/Cloud #99
Conversation
@LuisPiedra if you want to spin up a bitbucket server, you could clone https://github.com/Eernie/bitbucket-webhooks-plugin and install Atlassian plugin SDK and run |
I have a quick question: Will this build each tag as a separate Job? Or all the tags will be in the same Job (as different runs). |
return null; | ||
} | ||
if (getRepositoryType() == BitbucketRepositoryType.MERCURIAL) { | ||
return new MercurialRevision(head, revision); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need tag support in Mercurial to have this work correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks promising. Certainly some issues identified from a quick review
} else { | ||
throw new IllegalArgumentException("Either PullRequestSCMHead or BranchSCMHead required as parameter"); | ||
throw new IllegalArgumentException("Either PullRequestSCMHead, TagSCMHead or BranchSCMHead required as parameter"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to rephrase better... "either" corresponds to exactly two choices, there are now three choices so you will need to move from "Either A or B" to something like "Once of A, B or C"
* | ||
* @since 2.0.0 | ||
*/ | ||
public class TagSCMHead extends SCMHead { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Nope you do not what this class here at all. You probably want to extend https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/jenkins/plugins/git/GitTagSCMHead.java for a Git source and the corresponding MercurialTagSCMHead
once available in mercurial plugin
@@ -131,6 +132,8 @@ public SCMFileSystem build(@NonNull SCMSource source, @NonNull SCMHead head, @Ch | |||
String ref; | |||
if (head instanceof BranchSCMHead) { | |||
ref = head.getName(); | |||
} else if (head instanceof TagSCMHead) { | |||
ref = head.getName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May need additional changes here if there is a branch with the same name as a tag and the source is only selecting tags (so that the tag would win during fetch)
We may need to change ref
from being just the name to being a more fully specified ref that includes the prefix from which the ref is to be retrieved (so that this would become ref = "tags/" + head.getName()
and similar corresponding changes made elsewhere... but I haven't investigated this)
@Override | ||
@NonNull | ||
public List<BitbucketServerTag> getTags() throws IOException, InterruptedException { | ||
String url = String.format(API_TAGS_PATH, getUserCentricOwner(), repositoryName, 0, DEFAULT_PAGE_LIMIT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to encode the various URL segment parameters correctly, e.g. some will need to be Util.rawEncode
, some will need to be URLEncoder.encode
and you'll also need to check what happens for a tag that includes /
in the name, does the /
get encoded to %2F
or does it stay as a /
(and Bitbucket is not consistent in this regard, so you will need to test
throw new InterruptedException(); | ||
} | ||
Integer limit = page.getLimit(); | ||
url = String.format(API_TAGS_PATH, getUserCentricOwner(), repositoryName, page.getNextPageStart(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encoding of url stuff... or build on top of the PR for moving to URITemplates from damnhandy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#80 is the PR that should make all this easier
@LuisPiedra do you think you might be able to continue developing this functionality? Would love to see this functionality implemented/happy to try and help where I can! |
Based on current functionality already available on GitHub plugin.
Not tested for Stash (BitBucket Server)