Skip to content

Commit fa32315

Browse files
authored
Merge pull request #16 from jlafourc/add-create-tag
Add an API to create tags in a repository
2 parents 2ffa20d + 2dca5b0 commit fa32315

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/main/java/org/gitlab4j/api/RepositoryApi.java

+24
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,30 @@ public Branch createBranch(Integer projectId, String branchName, String ref) thr
7373
return (response.readEntity(Branch.class));
7474
}
7575

76+
/**
77+
* Creates a tag for the project. Support as of version 6.8.x
78+
*
79+
* POST /projects/:id/repository/tags
80+
*
81+
* @param projectId the project to create the branch for
82+
* @param tagName the name of the tag to create
83+
* @param ref Source to create the tag from, can be an existing branch, tag or commit SHA
84+
* @param message (optional) - Creates annotated tag.
85+
* @param release_description (optional) - Add release notes to the git tag and store it in the GitLab database.
86+
* @return the tag info for the created tag
87+
* @throws GitLabApiException
88+
*/
89+
public Tag createTag(Integer projectId, String tagName, String ref, String message, String release_description) throws GitLabApiException {
90+
91+
Form formData = new GitLabApiForm()
92+
.withParam("tag_name", tagName, true)
93+
.withParam("ref", ref, true)
94+
.withParam("message", message, false)
95+
.withParam("release_description", release_description, false);
96+
Response response = post(Response.Status.CREATED, formData.asMap(), "projects", projectId, "repository", "tags");
97+
return (response.readEntity(Tag.class));
98+
}
99+
76100
/**
77101
* Delete a single project repository branch. This is an idempotent function,
78102
* protecting an already protected repository branch will not produce an error.

0 commit comments

Comments
 (0)