Hi,
I am trying to create a plugin that allows the user to create a tag on a commit on the master branch. I am trying to use the API /rest/git/1.0/projects/{projectKey}/repos/{repositorySlug}/tags. However, this throws me a 404 error. This is my ajax call:
var tagDetails = {"force":"true","message":"A new release tag","name":"release-tag","startPoint":"refs/heads/master","type":"ANNOTATED"}; var link = "http://localhost:7990/stash/rest/git/1.0/projects/" + pageState.getProject.key + "/repos/" + pageState.getRepository().slug + "/tags"; alert(link); $.ajax({ url: link, type: 'post', contentType: 'application/json', dataType: 'json', data: tagDetails, success: function (data) { alert("here"); } });
The version of Stash I am using is v3.3.1.
Is there anything that I am doing wrong?
EDIT:
Also, when I upload my plugin the console shows me the following error, I'm not sure if it is related to my problem.
[INFO] [talledLocalContainer] 2015-04-06 15:47:08,327 ERROR [UpmAsynchronousTaskManager:thread-4] admin @J7TYBYx947x1081x0 1fgqf3v 0:0:0:0:0:0:0:1 "POST /rest/plugins/1.0/ HTTP/1.1" c.a.p.m.PrefixDelegatingModuleFactory Detected an error instantiating the module via Spring. This usually means that you haven't created a <component-import> for the interface you're trying to use. https://developer.atlassian.com/x/TAEr for more details.
Community moderators have prevented the ability to post new answers.
Hello Vallerine,
Thank you for your question.
Please, notice /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags provides the GET method only.
Please, refer to http://git-scm.com/book/en/v2/Git-Basics-Tagging documentation for further information.
If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.
Thank you for your understanding.
—
Kind regards,
Rafael P. Sperafico
Atlassian Support
Hi Rafael, as of 3.8 we support tag management (including creation / deletion) via the REST API https://developer.atlassian.com/static/rest/stash/3.8.0/stash-scm-git-rest.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tim Pettersen , I didn't see any mention of that new support for tag management in the 3.8 release notes. https://confluence.atlassian.com/display/STASH/Stash+3.8+release+notes
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tim Pettersen , I just launched a debug version of Stash 3.8.0 and looked in the Rest api browser. The post and delete operations are not public api. Does that mean that my build system won't be able to call them and it can only be called from Stash? Do I have to make a public Rest api that will call them?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Mathieu Yargeau non-public APIs typically mean that there are no backwards compatibility guarantees, so they may change in a future release (though in practice this rarely happens). You can call them as usual from a separate application. @Jacob Eggers it should be, I believe. Is it a repository with a very large number of tags? Regardless I'd recommend raising an issue in the Stash project at https://support.atlassian.com if you're getting timeouts.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vallerine,
I haven't tested this, but from a quick look at your code I think:
pageState.getProject.key
should be:
pageState.getProject().key
Let me know if that helps!
cheers,
Tim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Tim, Nope, that doesn't help. My Javascript console shows the following errors: 1) Uncaught TypeError: undefined is not a function 2) POST http://localhost:7990/stash/rest/git/1.0/projects/PROJECT_1/repos/rep_1/tags 404 (Not Found)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, I just realized you're using Stash 3.3.1 - I believe that REST API was introduced in Stash 3.8. Can you upgrade and test in Stash 3.8+?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well, I'm trying to create a plugin for my company's instance of stash which is still at 3.3.1 and i'm not allowed to upgrade it. Is there any other way that I could create this plugin? Using GitTag and GitTagCreateBuilder maybe? Are there any examples of using these classes?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you have a commercial Stash license, you're eligible for the Stash source code (see https://developer.atlassian.com/stash/docs/latest/how-tos/building-stash-from-source-code.html). I'd recommend downloading it and looking at how it's scm-git-rest plugin (which provides the tag end-point) is implemented in version 3.8. cheers, Tim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.