Wiki source code of Bitbucket
Version 1.1 by DevOps-as-a-Service Operator on 2025/02/05 11:33
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | DevOps as a Service includes a hosted and managed version of Atlassian Bitbucket. Please check out the[[ vendor provided documentation>>https://confluence.atlassian.com/bitbucketserver||shape="rect"]] to learn how to work in Bitbucket projects. You can skip any documentation related to Bitbucket installation or administration. | ||
2 | |||
3 | |||
4 | {{toc/}} | ||
5 | |||
6 | |||
7 | = Log in to Bitbucket = | ||
8 | |||
9 | Select **Projects** in SDPortal, then click on //Bitbucket// in the **Tools** section: | ||
10 | |||
11 | [[image:attach:image2019-8-7_15-44-58.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" width="1109"]] | ||
12 | |||
13 | Log in to Bitbucket with your **username** and **password**. | ||
14 | |||
15 | If there are no repositories in the project you can **Create a repository** or you can **Import a repositories **to a project | ||
16 | |||
17 | [[image:attach:image2019-8-7_15-46-42.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" width="1109"]] | ||
18 | |||
19 | = Create a Repository = | ||
20 | |||
21 | To create an empty repository click Create repository or the + sign on the left, and the a new window appears: | ||
22 | |||
23 | [[image:attach:image2019-8-7_15-55-36.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" width="800"]] | ||
24 | |||
25 | Now an empty repository is created and the hints for further steps are displayed. | ||
26 | |||
27 | [[image:attach:image2019-8-7_15-57-58.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" width="1109"]] | ||
28 | |||
29 | {{info}} | ||
30 | ℹ For further tips on creating and using repositories in Bitbucket visit the [[vendor's website.>>url:https://confluence.atlassian.com/bitbucket/create-a-git-repository-759857290.html||shape="rect"]] | ||
31 | {{/info}} | ||
32 | |||
33 | = Manage Repositories using SSH Connection = | ||
34 | |||
35 | It is also possible to manage your repository by using SSH connection. | ||
36 | |||
37 | In your customer environment the URL (containing the created project) refers to the repository. | ||
38 | |||
39 | As an example to clone a repository the following command can be used: | ||
40 | |||
41 | {{code}} | ||
42 | git clone https://CUSTOMER.devops.t-systems.net/bitbucket/scm/PROJECT/REPO.git | ||
43 | {{/code}} | ||
44 | |||
45 | (% style="color:#1d1c1d" %)For SSH connection the same command can be used like this: | ||
46 | |||
47 | {{code}} | ||
48 | git clone ssh://CUSTOMER.devops.t-systems.net:7999/PROJECT/REPO.git | ||
49 | {{/code}} | ||
50 | |||
51 | {{info}} | ||
52 | ℹ If you are not familiar with using git, you can read about the git basics on the [[vendor's website>>url:https://www.atlassian.com/git||shape="rect"]]. | ||
53 | {{/info}} | ||
54 | |||
55 | = Manage Projects in Bitbucket = | ||
56 | |||
57 | If you are assigned to more than one project you can see these by clicking **Projects:** | ||
58 | |||
59 | [[image:attach:image2019-8-7_15-49-17.png||data-xwiki-image-style-border="true" height="84"]] | ||
60 | |||
61 | In this example the user is assigned to CCTS and SHOWCASE projects. | ||
62 | |||
63 | [[image:attach:image2019-8-7_16-2-22.png||data-xwiki-image-style-border="true" height="250"]] | ||
64 | |||
65 | If you click on the project's name the (created or imported) repositories will appear. In this example an imported repository can be found by clicking **Showing DevOps as a Service capabilities.** | ||
66 | |||
67 | [[image:attach:image2019-8-7_16-7-57.png||data-xwiki-image-style-border="true" height="240"]] | ||
68 | |||
69 | If you click on the repository's name (in this example **sdcloud-caas-nginx-demo**) the source content will appear: | ||
70 | |||
71 | [[image:attach:image2019-8-7_16-10-6.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" width="800"]] | ||
72 | |||
73 | On the left side you can see the options such as creating a //branch, pull request,// or// fork//. | ||
74 | |||
75 | = Roles in SDPortal and roles in Bitbucket = | ||
76 | |||
77 | The roles are handled automatically by SDPortal, and when a user is created in SDPortal with a role in a project all permissions are automatically set in Bitbucket too. | ||
78 | |||
79 | [[image:attach:image2019-8-7_14-41-56.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" width="1109"]] | ||
80 | |||
81 | In this example the user (Barney Rubble) in SDPortal has Developer role in the project. | ||
82 | |||
83 | [[image:attach:image2019-8-7_14-40-12.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" width="1109"]] | ||
84 | |||
85 | In Bitbucket the permissions connected to this role are automatically created: | ||
86 | |||
87 | [[image:attach:image2019-8-7_14-33-39.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" width="1109"]] | ||
88 | |||
89 | This example shows that the user with Developer role has Write and Read but no Admin rights. | ||
90 | |||
91 | Above you can see how the roles in the project are handled in Bitbucket's project permissions: | ||
92 | |||
93 | (% class="relative-table wrapped" style="width:27.3777%" %) | ||
94 | |=(% class="active" rowspan="2" style="text-align: center" %)SDPortal role|=(% class="active" colspan="3" style="text-align: center" %) User access in Bitbucket | ||
95 | |=(% class="active" %)Admin|=(% class="active" %)Write|=(% class="active" %)Read | ||
96 | |=(% class="active" %)Viewer|❌|❌|❌ | ||
97 | |=(% class="active" %)Developer|❌|✅|✅ | ||
98 | |=(% class="active" %)Master|❌|✅|✅ | ||
99 | |=(% class="active" %)Admin|✅|✅|✅ | ||
100 | |||
101 | = Create a branch from an issue in Jira = | ||
102 | |||
103 | {{info}} | ||
104 | ℹ To create branches in Jira Software it must be connected with Bitbucket, this is managed by SDPortal automatically. | ||
105 | {{/info}} | ||
106 | |||
107 | In the **Development** panel, click** Create Branch:** | ||
108 | |||
109 | //[[image:attach:image2019-10-18_17-34-57.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" width="500"]]// | ||
110 | |||
111 | This will open up Bitbucket's create branch screen, choose the repository where you want to create the branch. | ||
112 | |||
113 | [[image:attach:image2019-10-18_17-35-49.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" width="500"]] | ||
114 | |||
115 | **Select** the **Branch type** and **Branch name **(Bitbucket may suggest a Branch type based on the Jira Software issue type, when the branching model is configured) | ||
116 | |||
117 | A branch type can be **Bugfix**, **Feature**, **Hotfix**, **Release** or **Custom**. | ||
118 | |||
119 | [[image:attach:image2019-10-18_17-49-47.png||data-xwiki-image-style-border="true" height="238"]] | ||
120 | |||
121 | In the Branch from option a branch can be selected from existing branches, at first time only the master branch can be selected. | ||
122 | |||
123 | Click **Create branch **to continue. | ||
124 | |||
125 | Once the new branch is created, Bitbucket takes you to the file listing. You can now //pull// to your local repository and s//witch to the new branch//. | ||
126 | |||
127 | In this example it is the Jhipster showcase, a repository to demonstrate tool capabilities: | ||
128 | |||
129 | [[image:attach:image2019-10-18_17-37-40.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" width="1000"]] | ||
130 | |||
131 | Switching back to **Jira** the issue now displays the **created branch**: | ||
132 | |||
133 | [[image:attach:image2019-10-18_17-38-45.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" width="500"]] | ||
134 | |||
135 | The branching models and issue types are mapped in this way: | ||
136 | |||
137 | (% class="wrapped" %) | ||
138 | |=(% style="background-color: rgb(239, 239, 239);" %)((( | ||
139 | Jira Software issue type | ||
140 | )))|=(% style="background-color: rgb(239, 239, 239);" %)((( | ||
141 | Bitbucket branch type | ||
142 | ))) | ||
143 | |(% style="text-align:left" %)((( | ||
144 | Bug | ||
145 | )))|(% style="text-align:left" %)((( | ||
146 | Bugfix | ||
147 | |||
148 | (Feature if Bugfix type is not enabled) | ||
149 | ))) | ||
150 | |(% style="text-align:left" %)((( | ||
151 | Story | ||
152 | )))|(% style="text-align:left" %)((( | ||
153 | Feature | ||
154 | ))) | ||
155 | |(% style="text-align:left" %)((( | ||
156 | Other | ||
157 | )))|(% style="text-align:left" %)((( | ||
158 | Other/Custom | ||
159 | ))) | ||
160 | |||
161 | = View a branch connected to an issue in Jira = | ||
162 | |||
163 | If there has been a branch created in Jira (as a result the branch name should begin with the ticket id) the development tab will appear in the Jira ticket. | ||
164 | |||
165 | There you will have direct links to the existing branch, commits, and pull requests. | ||
166 | |||
167 | In this example you can see the Development tab of the Jira ticket named //SDCLOUD-1246.// | ||
168 | |||
169 | //[[image:attach:image2019-8-8_11-11-6.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" width="1109"]]// | ||
170 | |||
171 | If you push your code into Bitbucket, and write the Jira ticket's id in the commit section, as a result a direct link will be created in Bitbucket to the corresponding Jira ticket. | ||
172 | |||
173 | In this example in a Bitbucket repository the linked ticket's name is //SDCLOUD-1246.// | ||
174 | |||
175 | [[image:attach:image2019-8-7_14-14-43.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" width="700"]] | ||
176 | |||
177 | = (% style="letter-spacing:-0.01em" %)Using Smart Commits(%%) = | ||
178 | |||
179 | Smart Commits allow repository committers to perform actions such as transitioning Jira Software issues by embedding specific commands into their commit messages. | ||
180 | |||
181 | You can: | ||
182 | |||
183 | * comment on issues | ||
184 | * record time tracking information against issues | ||
185 | * transition issues to any status defined in the Jira Software project's workflow. | ||
186 | |||
187 | Each Smart Commit message must not span more than one line (i.e. you cannot use a carriage return in the command), but you can add multiple commands to the same line. | ||
188 | |||
189 | == Smart Commit commands == | ||
190 | |||
191 | The basic command line syntax for a Smart Commit message is: | ||
192 | |||
193 | {{code language="none"}} | ||
194 | <ignored text> <ISSUE_KEY> <ignored text> #<COMMAND> <optional COMMAND_ARGUMENTS> | ||
195 | {{/code}} | ||
196 | |||
197 | Any text between the issue key and the Smart Commit command is ignored. | ||
198 | |||
199 | There are three Smart Commit commands you can use in your commit messages: | ||
200 | |||
201 | 1. ((( | ||
202 | **comment** | ||
203 | ))) | ||
204 | 1. ((( | ||
205 | **time** | ||
206 | ))) | ||
207 | 1. ((( | ||
208 | **transition** | ||
209 | ))) | ||
210 | |||
211 | == Comment == | ||
212 | |||
213 | (% style="color:#003366" %)**Description**(%%) | ||
214 | Adds a comment to a JIRA Software issue. | ||
215 | |||
216 | (% style="color:#003366" %)**Syntax** | ||
217 | |||
218 | (% class="code" %) | ||
219 | ((( | ||
220 | <ignored text> ISSUE_KEY <ignored text> #comment <comment_string> | ||
221 | ))) | ||
222 | |||
223 | (% style="color:#003366" %)**Example** | ||
224 | |||
225 | (% class="code" %) | ||
226 | ((( | ||
227 | JRA-34 #comment corrected indent issue | ||
228 | ))) | ||
229 | |||
230 | (% style="color:#003366" %)**Notes**(%%) | ||
231 | The committer's email address must match the email address of a single JIRA Software user with permission to comment on issues in that particular project. | ||
232 | |||
233 | == Time == | ||
234 | |||
235 | (% style="color:#003366" %)**Description** | ||
236 | |||
237 | Records [[time tracking information>>url:https://confluence.atlassian.com/jirasoftwareserver071/logging-work-on-issues-800707273.html||shape="rect" class="conf-macro output-inline"]] against an issue. | ||
238 | |||
239 | (% style="color:#003366" %)**Syntax** | ||
240 | |||
241 | (% class="code" %) | ||
242 | ((( | ||
243 | <ignored text> ISSUE_KEY <ignored text> #time <value>w <value>d <value>h <value>m <comment_string> | ||
244 | ))) | ||
245 | |||
246 | (% style="color:#003366" %)**Example** | ||
247 | |||
248 | (% class="code" %) | ||
249 | ((( | ||
250 | JRA-34 #time 1w 2d 4h 30m Total work logged | ||
251 | ))) | ||
252 | |||
253 | (% style="color:#003366" %)**Notes** | ||
254 | |||
255 | This example records 1 week, 2 days, 4 hours and 30 minutes against the issue, and adds the comment {{code language="none"}}'Total work logged'{{/code}} in the **Work Log** tab of the issue. | ||
256 | |||
257 | * Each value for {{code language="none"}}w{{/code}}, {{code language="none"}}d{{/code}}, {{code language="none"}}h{{/code}} and {{code language="none"}}m{{/code}} can be a decimal number. | ||
258 | * The committer's email address must match the email address of a single JIRA Software user with permission to log work on an issue. | ||
259 | * Your system administrator must have [[enabled time tracking>>url:https://confluence.atlassian.com/adminjiraserver071/configuring-time-tracking-802593086.html||shape="rect" class="conf-macro output-inline"]] on your JIRA Software instance. | ||
260 | |||
261 | == Workflow transitions == | ||
262 | |||
263 | (% style="color:#003366" %)**Description** | ||
264 | |||
265 | Transitions a JIRA Software issue to a particular workflow state. | ||
266 | |||
267 | (% style="color:#003366" %)**Syntax** | ||
268 | |||
269 | (% class="code" %) | ||
270 | ((( | ||
271 | <ignored text> ISSUE_KEY <ignored text> #<transition_name> <comment_string> | ||
272 | ))) | ||
273 | |||
274 | (% style="color:#003366" %)**Example** | ||
275 | |||
276 | (% class="code" %) | ||
277 | ((( | ||
278 | JRA-090 #close Fixed this today | ||
279 | ))) | ||
280 | |||
281 | (% style="color:#003366" %)**Notes** | ||
282 | |||
283 | This example executes the close issue workflow transition for the issue and adds the comment '{{code language="none"}}Fixed this today{{/code}}' to the issue. Note that the comment is added automatically without needing to use the #comment command. | ||
284 | |||
285 | You can see the custom commands available for use with Smart Commits by visiting the JIRA Software issue and seeing its available workflow transitions: | ||
286 | |||
287 | 1. Open an issue in the project. | ||
288 | 1. Click **View Workflow** (near the issue's **Status**). | ||
289 | |||
290 | The Smart Commit only considers the part of a transition name before the first space. So, for a transition name such as {{code language="none"}}finish work{{/code}}, then specifying {{code language="none"}}#finish{{/code}} is sufficient. You must use hyphens to replace spaces when ambiguity can arise over transition names, for example: {{code language="none"}}#finish-work{{/code}}. | ||
291 | |||
292 | If a workflow has two valid transitions, such as: | ||
293 | |||
294 | * {{code language="none"}}Start Progress{{/code}} | ||
295 | * {{code language="none"}}Start Review{{/code}} | ||
296 | |||
297 | A Smart Commit with the action {{code language="none"}}#start{{/code}} is ambiguous because it could mean either of the two transitions. To specify one of these two transitions, fully qualify the transition you want by using either {{code language="none"}}#start-review{{/code}} or {{code language="none"}}#start-progress{{/code}}. | ||
298 | |||
299 | * When you resolve an issue with the {{code language="none"}}#resolve{{/code}} command, you cannot set the **Resolution** field with Smart Commits. | ||
300 | * If you want to add a comment during the transition, the transition must have a screen associated with it. | ||
301 | * The committer's email address must match the email address of a single JIRA Software user with the appropriate project permissions to transition issues. | ||
302 | |||
303 | {{info}} | ||
304 | ℹ For further tips on using Smart Commits in Bitbucket visit the [[vendor's website.>>url:https://confluence.atlassian.com/fisheye/using-smart-commits-960155400.html||shape="rect"]] | ||
305 | {{/info}} |