Skip to content

Commit 0f1ca19

Browse files
author
Marco Marche
committed
updated README - pipeline step info
1 parent 6b976c1 commit 0f1ca19

File tree

1 file changed

+69
-1
lines changed

1 file changed

+69
-1
lines changed

README.md

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Third, you need to add the Bitbucket OAuth Consumer credentials. You have two wa
7373
4. Click **Add** button.
7474
7. Select the desired credentials.
7575

76-
### Configure Jenkins to notify Bitbucket
76+
### Configure Jenkins to notify Bitbucket from a standard build
7777

7878
Once you have configured the credentials, configure jenkins to notify Bitbucket.
7979

@@ -82,6 +82,74 @@ Once you have configured the credentials, configure jenkins to notify Bitbucket.
8282
3. Select **Bitbucket notify build status**.
8383
4. Choose whether you want to notify the build status on Jenkins to Bitbucket.
8484

85+
### Pipeline step to notify Bitbucket
86+
87+
Once you have configured the credential, you can notify BitBucket from your Pipeline script through the `bitbucketStatusNotify` step.
88+
89+
#### Usage
90+
91+
The `bitbucketStatusNotify` step notifies the status of a build identified by a build key and build name to BitBucket.
92+
If `buildKey` and `buildName` parameters are not provided, a standard name will be assigned to the build (NameOfYourJob #numberOfBuild - eg. MyProject #32).
93+
When a `FAILED` status is sent to BitBucket, `bitbucketStatusNotify` throws an exception terminating your Pipeline.
94+
95+
```groovy
96+
...
97+
stage 'Build'
98+
bitbucketStatusNotify(
99+
buildState: 'INPROGRESS',
100+
buildKey: 'build',
101+
buildName: 'Build'
102+
)
103+
try {
104+
myBuildFunction()
105+
bitbucketStatusNotify(
106+
buildState: 'SUCCESSFUL',
107+
buildKey: 'build',
108+
buildName: 'Build'
109+
)
110+
} catch(Exception e) {
111+
bitbucketStatusNotify(
112+
buildState: 'FAILED',
113+
buildKey: 'build',
114+
buildName: 'Build',
115+
buildDescription: 'Something went wrong with build!'
116+
)
117+
}
118+
stage 'Test'
119+
bitbucketStatusNotify(
120+
buildState: 'INPROGRESS',
121+
buildKey: 'test',
122+
buildName: 'Test'
123+
)
124+
try {
125+
myTestFunction()
126+
bitbucketStatusNotify(
127+
buildState: 'SUCCESSFUL',
128+
buildKey: 'test',
129+
buildName: 'Test'
130+
)
131+
} catch(Exception e) {
132+
bitbucketStatusNotify(
133+
buildState: 'FAILED',
134+
buildKey: 'test',
135+
buildName: 'Test',
136+
buildDescription: 'Something went wrong with tests!'
137+
)
138+
}
139+
...
140+
```
141+
142+
#### API Summary
143+
144+
Parameter:
145+
146+
| Name | Type | Optional | Description |
147+
| --- | --- | --- | --- |
148+
| `buildState` | `"INPROGRESS"|"SUCCESSFUL"|"FAILED"` | no | The status of the current build phase
149+
| `buildKey` | String | yes | The unique key identifying the current build phase
150+
| `buildName` | String | yes | The build phase's name shown on BitBucket
151+
| `buildDescription` | String | yes | The build phase's description shown on BitBucket
152+
85153
## Contributions
86154

87155
Contributions are welcome! For feature requests and bug reports please read the following Wiki page for guidelines on [how to submit an issue][how-to-submit-issue].

0 commit comments

Comments
 (0)