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

[JENKINS-47254] Support for building tags for Bitbucket Server/Cloud #99

Closed
wants to merge 2 commits into from

Conversation

LuisPiedra
Copy link
Contributor

Based on current functionality already available on GitHub plugin.

Not tested for Stash (BitBucket Server)

@jetersen
Copy link
Member

@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 atlas-run inside the repo :)

@abishek3876
Copy link

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).
I know tags are very similar to branches in Git and hence each should be in a separate Job, but generally each tag will be built only once and it is going to stay forever, so it would make sense for many use-cases to put all the tag builds in a single Job as different runs.
For example, if we use tags to mark each release, then putting all the releases into a single Job as different builds is going to be much easier to manage.

return null;
}
if (getRepositoryType() == BitbucketRepositoryType.MERCURIAL) {
return new MercurialRevision(head, revision);
Copy link
Member

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

Copy link
Member

@stephenc stephenc left a 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");
Copy link
Member

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 {
Copy link
Member

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();
Copy link
Member

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);
Copy link
Member

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(),
Copy link
Member

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

Copy link
Member

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

@chris5287
Copy link

@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!

@LuisPiedra LuisPiedra closed this Jun 13, 2018
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.

None yet

5 participants