Skip to content

Commit 89ddddb

Browse files
authored
Improve webhooks user and trait documentation (#923)
1 parent 40dc843 commit 89ddddb

File tree

7 files changed

+29
-17
lines changed

7 files changed

+29
-17
lines changed

docs/USER_GUIDE.adoc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,26 @@ allows to trigger builds on branches and pull requests just when a new commit is
8989
service to listen to these webhook requests and acts accordingly by triggering a new reindex and finally
9090
triggering builds on matching branches or pull requests.
9191

92-
Go to "Manage Jenkins" / "Configure System" and locate _Bitbucket Endpoints_. For every endpoint where you want webhooks registered automatically,
92+
Go to "Manage Jenkins" / "System" and locate _Bitbucket Endpoints_. For every endpoint where you want webhooks registered automatically,
9393
check "Manage hooks" and select a "Credential" with enough access to add webhooks to repositories. Since the Credential is used at the system level,
9494
it can be a System scoped credential, which will restrict its usage from Pipelines.
95+
You can setup a custom Jenkins URL to be used as callback URL by the webhooks.
96+
97+
For Bitbucket Server only it is possible chose which webhooks implementation server side to use:
98+
99+
- Native implementation will configure the webhooks provided by default with the Server, so it will always be available.
100+
101+
- Plugin implementation relies on the configuration available via specific APIs provided by the https://marketplace.atlassian.com/apps/1215474/post-webhooks-for-bitbucket?tab=overview&hosting=datacenter[Post Webhooks for Bitbucket] plugin itself. To get it worked plugin must be already pre-installed on the server instance. This provider allows custom settings managed by the _ignore committers_ trait. _Note: This specific implementation will be moved to an individual repository as soon as https://issues.jenkins.io/browse/JENKINS-74913[JENKINS-74913] is implemented._
102+
103+
image::images/screenshot-14.png[scaledwidth=90%]
95104

96105
For both Bitbucket _Multibranch Pipelines_ and _Organization folders_ there is an "Override hook management" behavior
97106
to opt out or adjust system-wide settings.
98107

99108
image::images/screenshot-4.png[scaledwidth=90%]
100109

101110
IMPORTANT: In order to have the auto-registering process working fine the Jenkins base URL must be
102-
properly configured in _Manage Jenkins_ » _Configure System_
111+
properly configured in _Manage Jenkins_ » _System_
103112

104113
[id=bitbucket-creds-config]
105114
== Credentials configuration
@@ -173,4 +182,4 @@ In case of slow network, you can increase socket timeout using the link:https://
173182
[source,groovy]
174183
----
175184
System.setProperty("http.socket.timeout", "300") // 5 minutes
176-
----
185+
----

docs/images/screenshot-14.png

63.7 KB
Loading

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketBuildStatusNotifications.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private static void createStatus(@NonNull Run<?, ?> build, @NonNull TaskListener
129129
statusDescription = StringUtils.defaultIfBlank(buildDescription, "This commit looks good.");
130130
state = BitbucketBuildStatus.Status.SUCCESSFUL;
131131
} else if (Result.UNSTABLE.equals(result)) {
132-
statusDescription = StringUtils.defaultIfBlank(buildDescription, "This commit has test failures.");
132+
statusDescription = StringUtils.defaultIfBlank(buildDescription, "This commit may have some failing tests.");
133133
if (context.sendSuccessNotificationForUnstableBuild()) {
134134
state = BitbucketBuildStatus.Status.SUCCESSFUL;
135135
} else {
@@ -182,11 +182,11 @@ private static void sendNotifications(BitbucketSCMSource source, Run<?, ?> build
182182
if (sourceContext.notificationsDisabled()) {
183183
return;
184184
}
185-
SCMRevision r = SCMRevisionAction.getRevision(source, build);
186-
if (r == null) {
185+
SCMRevision rev = SCMRevisionAction.getRevision(source, build);
186+
if (rev == null) {
187187
return;
188188
}
189-
String hash = getHash(r);
189+
String hash = getHash(rev);
190190
if (hash == null) {
191191
return;
192192
}
@@ -196,14 +196,14 @@ private static void sendNotifications(BitbucketSCMSource source, Run<?, ?> build
196196

197197
String key;
198198
BitbucketApi bitbucket;
199-
if (r instanceof PullRequestSCMRevision) {
199+
if (rev instanceof PullRequestSCMRevision) {
200200
listener.getLogger().println("[Bitbucket] Notifying pull request build result");
201-
PullRequestSCMHead head = (PullRequestSCMHead) r.getHead();
201+
PullRequestSCMHead head = (PullRequestSCMHead) rev.getHead();
202202
key = getBuildKey(build, head.getOriginName(), shareBuildKeyBetweenBranchAndPR);
203203
bitbucket = source.buildBitbucketClient(head);
204204
} else {
205205
listener.getLogger().println("[Bitbucket] Notifying commit build result");
206-
key = getBuildKey(build, r.getHead().getName(), shareBuildKeyBetweenBranchAndPR);
206+
key = getBuildKey(build, rev.getHead().getName(), shareBuildKeyBetweenBranchAndPR);
207207
bitbucket = source.buildBitbucketClient();
208208
}
209209
createStatus(build, listener, bitbucket, key, hash);

src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/Messages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ SSHCheckoutTrait.useAgentKey=- use build agent''s key -
3535
WebhookRegistrationTrait.disableHook=Disable hook management
3636
WebhookRegistrationTrait.displayName=Override hook management
3737
WebhookRegistrationTrait.useItemHook=Use item credentials for hook management
38-
WebhookConfigurationTrait.displayName=Set ignored committers
38+
WebhookConfigurationTrait.displayName=Configure committers to be ignored by the webhook
3939
PullRequestSCMHead.Pronoun=Pull Request
4040
BranchSCMHead.Pronoun=Branch
4141
BitbucketTagSCMHead.Pronoun=Tag
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?jelly escape-by-default='true'?>
22
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
3-
<f:entry title="${%Ignore committers}" field="committersToIgnore">
3+
<f:entry title="${%Prevents webhook from users ids}" field="committersToIgnore">
44
<f:textbox/>
55
</f:entry>
66
</j:jelly>
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<div>
22
<p>
3-
Sets the value for committersToIgnore in the Bitbucket Webhook. Value should be a comma separated string.
3+
Comma separated list of user ids in bitbucket to ignore commits from for triggering the webhook.
44
</p>
55
<p>
6-
committerToIgnore is used to prevent triggering Jenkins builds when commits by certain users
7-
are made.
6+
committerToIgnore is used exclusively by the "Post Webhooks for Bitbucket" plugin to prevent a server notification
7+
from being sent to the Jenkins instance to avoid triggering builds when commits are made by certain users.
88
</p>
9-
</div>
9+
<p>
10+
References could be found <a href="https://help.moveworkforward.com/BPW/how-to-manage-configurations-using-post-webhooks-f#HowtomanageconfigurationsusingPostWebhooksforBitbucketAPIs?-UpdateapostwebhookbyID">here</a>.
11+
</p>
12+
</div>

src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/help-webhookImplementation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Determines which Webhook implementation is to be used:
33
<dl>
44
<dt>Plugin</dt>
5-
<dd>The third party Webhook implementation provided by a plugin.</dd>
5+
<dd>The third party Webhook implementation provided by a <a href="https://marketplace.atlassian.com/apps/1215474/post-webhooks-for-bitbucket?tab=overview&hosting=datacenter">Post Webhooks for Bitbucket</a> plugin.</dd>
66
<dd>Please note cloning from mirror is not supported with this implementation.</dd>
77

88
<dt>Native</dt>

0 commit comments

Comments
 (0)