@@ -140,6 +140,35 @@ void test_status_notification_name_when_UseReadableNotificationIds_is_true(@NonN
140
140
ArgumentCaptor <BitbucketBuildStatus > captor = ArgumentCaptor .forClass (BitbucketBuildStatus .class );
141
141
verify (apiClient ).postBuildStatus (captor .capture ());
142
142
assertThat (captor .getValue ().getKey ()).isEqualTo ("P/BRANCH-JOB" );
143
+ assertThat (captor .getValue ().getParent ()).isEqualTo ("P" );
144
+ }
145
+
146
+ @ Issue ("JENKINS-75203" )
147
+ @ Test
148
+ void test_status_notification_parent_key_null_if_cloud_is_true (@ NonNull JenkinsRule r ) throws Exception {
149
+ StreamBuildListener taskListener = new StreamBuildListener (System .out , StandardCharsets .UTF_8 );
150
+ URL jenkinsURL = new URL ("http://example.com:" + r .getURL ().getPort () + r .contextPath + "/" );
151
+ JenkinsLocationConfiguration .get ().setUrl (jenkinsURL .toString ());
152
+
153
+ String serverURL = BitbucketCloudEndpoint .SERVER_URL ;
154
+
155
+ BitbucketBuildStatusNotificationsTrait trait = new BitbucketBuildStatusNotificationsTrait ();
156
+
157
+ WorkflowRun build = prepareBuildForNotification (r , trait , serverURL );
158
+ doReturn (Result .SUCCESS ).when (build ).getResult ();
159
+
160
+ FilePath workspace = r .jenkins .getWorkspaceFor (build .getParent ());
161
+
162
+ BitbucketApi apiClient = mock (BitbucketCloudApiClient .class );
163
+ BitbucketMockApiFactory .add (serverURL , apiClient );
164
+
165
+ JobCheckoutListener listener = new JobCheckoutListener ();
166
+ listener .onCheckout (build , null , workspace , taskListener , null , SCMRevisionState .NONE );
167
+
168
+ ArgumentCaptor <BitbucketBuildStatus > captor = ArgumentCaptor .forClass (BitbucketBuildStatus .class );
169
+ verify (apiClient ).postBuildStatus (captor .capture ());
170
+ assertThat (captor .getValue ().getKey ()).isNotEmpty ();
171
+ assertThat (captor .getValue ().getParent ()).isNull ();
143
172
}
144
173
145
174
@ Issue ("JENKINS-74970" )
@@ -173,6 +202,7 @@ void test_status_notification_on_fork(@NonNull JenkinsRule r) throws Exception {
173
202
assertThat (captor .getValue ()).satisfies (status -> {
174
203
assertThat (status .getHash ()).isEqualTo (prRevision .getHash ());
175
204
assertThat (status .getKey ()).isEqualTo (DigestUtils .md5Hex ("p/branch-job" ));
205
+ assertThat (status .getParent ()).isNull ();
176
206
assertThat (status .getRefname ()).isEqualTo ("refs/heads/" + scmHead .getBranchName ());
177
207
});
178
208
}
0 commit comments