Skip to content

Commit 8a90f7a

Browse files
committed
Merge branch 'master' of github.com:AstroMatt/atlassian-python-api
2 parents 5be496f + 80d1a51 commit 8a90f7a

File tree

4 files changed

+95
-21
lines changed

4 files changed

+95
-21
lines changed

atlassian/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.10.1
1+
1.10.2

atlassian/bitbucket.py

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,63 @@ def get_tags(self, project, repository, filter='', limit=99999):
158158
fixed system limits. Default by built-in method: 99999
159159
:return:
160160
"""
161-
url = '/rest/api/1.0/projects/{project}/repos/{repository}/tags'.format(project=project,
162-
repository=repository)
161+
url = 'rest/api/1.0/projects/{project}/repos/{repository}/tags'.format(project=project,
162+
repository=repository)
163163
url += '?limit={limit}&filterText={filter}'.format(limit=limit,
164164
filter=filter)
165165
return (self.get(url) or {}).get('values')
166166

167+
def get_project_tags(self, project, repository, tag_name):
168+
"""
169+
Retrieve a tag in the specified repository.
170+
The authenticated user must have REPO_READ permission for the context repository to call this resource.
171+
Search uri is api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags/{name:.*}
172+
:param project:
173+
:param repository:
174+
:param tag_name: OPTIONAL:
175+
:return:
176+
"""
177+
url = 'rest/api/1.0/projects/{project}/repos/{repository}/tags/{tag}'.format(project=project,
178+
repository=repository,
179+
tag=tag_name)
180+
return self.get(url, not_json_response=True)
181+
182+
def set_tag(self, project, repository, tag_name, commit_revision, description=None):
183+
"""
184+
Creates a tag using the information provided in the {@link RestCreateTagRequest request}
185+
The authenticated user must have REPO_WRITE permission for the context repository to call this resource.
186+
:param project:
187+
:param repository:
188+
:param tag_name:
189+
:param commit_revision: commit hash
190+
:param description: OPTIONAL:
191+
:return:
192+
"""
193+
url = 'rest/api/1.0/projects/{project}/repos/{repository}/tags'.format(project=project,
194+
repository=repository)
195+
body = {}
196+
if tag_name is not None:
197+
body['name'] = tag_name
198+
if tag_name is not None:
199+
body['startPoint'] = commit_revision
200+
if tag_name is not None:
201+
body['message'] = description
202+
return self.post(url, data=body)
203+
204+
def delete_tag(self, project, repository, tag_name):
205+
"""
206+
Creates a tag using the information provided in the {@link RestCreateTagRequest request}
207+
The authenticated user must have REPO_WRITE permission for the context repository to call this resource.
208+
:param project:
209+
:param repository:
210+
:param tag_name:
211+
:return:
212+
"""
213+
url = 'rest/git/1.0/projects/{project}/repos/{repository}/tags/{tag}'.format(project=project,
214+
repository=repository,
215+
tag=tag_name)
216+
return self.delete(url)
217+
167218
def get_diff(self, project, repository, path, hash_oldest, hash_newest):
168219
url = 'rest/api/1.0/projects/{project}/repos/{repository}/compare/diff/{path}'.format(project=project,
169220
repository=repository,
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# coding: utf8
2-
from atlassian import Bamboo
3-
import os
4-
5-
BAMBOO_URL = os.environ.get('BAMBOO_URL', 'http://localhost:8085')
6-
ATLASSIAN_USER = os.environ.get('ATLASSIAN_USER', 'admin')
7-
ATLASSIAN_PASSWORD = os.environ.get('ATLASSIAN_PASSWORD', 'admin')
8-
9-
bamboo = Bamboo(
10-
url=BAMBOO_URL,
11-
username=ATLASSIAN_USER,
12-
password=ATLASSIAN_PASSWORD)
13-
14-
agent_status = bamboo.agent_status()
15-
print(agent_status)
16-
17-
activity = bamboo.activity()
18-
print(activity)
1+
# coding: utf8
2+
from atlassian import Bamboo
3+
import os
4+
5+
BAMBOO_URL = os.environ.get('BAMBOO_URL', 'http://localhost:8085')
6+
ATLASSIAN_USER = os.environ.get('ATLASSIAN_USER', 'admin')
7+
ATLASSIAN_PASSWORD = os.environ.get('ATLASSIAN_PASSWORD', 'admin')
8+
9+
bamboo = Bamboo(
10+
url=BAMBOO_URL,
11+
username=ATLASSIAN_USER,
12+
password=ATLASSIAN_PASSWORD)
13+
14+
agent_status = bamboo.agent_status()
15+
print(agent_status)
16+
17+
activity = bamboo.activity()
18+
print(activity)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from atlassian import Bitbucket
2+
3+
"""This example shows how to create, get and delete tags"""
4+
5+
bitbucket = Bitbucket(
6+
url='http://localhost:7990',
7+
username='admin',
8+
password='admin')
9+
10+
if __name__ == '__main__':
11+
response = bitbucket.set_tag(project='gonchik.tsymzhitov',
12+
repository='gonchik',
13+
tag_name='test1',
14+
commit_revision='ebcf5fdffa0',
15+
description='Stable release')
16+
print("Response after set_tag method")
17+
print(response)
18+
19+
response = bitbucket.get_project_tags(project='INT', repository='jira-plugins', tag_name='test1')
20+
print("Retrieve tag")
21+
print(response)
22+
print("Remove tag")
23+
bitbucket.delete_tag(project='INT', repository='jira-plugins', tag_name='test1')

0 commit comments

Comments
 (0)