Skip to content

Conversation

@LakshyaBagani
Copy link

@LakshyaBagani LakshyaBagani commented Jan 20, 2026

The Jenkins core race condition fix hides the 'Build Now' button (display: none) until JavaScript loads. This caused ATH tests to time out because clickLink('Build Now') couldn't find the hidden element.

This fix adds waitFor(by.link('Build Now')) before clicking, which polls until the element is visible (with ATH's default 120s timeout).

Fixes timeouts in:

  • core.FreestyleJobTest.doNotDiscardSuccessfulBuilds
  • core.FreestyleJobTest.archiveArtifacts
  • core.TriggerRemoteBuildsTest.triggerBuildRemotely

Testing done

The fix was tested by reviewing the CI failure logs which showed all 3 tests failing at Job.scheduleBuild(Job.java:368) when calling clickLink("Build Now"). The tests timed out after 120 seconds waiting for an element that was hidden.

The waitFor(by.link("Build Now")) method polls until the element becomes visible, using ATH's existing wait infrastructure. This is the same pattern already used elsewhere in the codebase (e.g., the notification-bar wait on the following line).

Related upstream change: jenkinsci/jenkins#26124 (Jenkins core race condition fix)

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

Desired revierwe
@timja @mawinter69 @MarkEWaite

The Jenkins core race condition fix hides the 'Build Now' button
(display: none) until JavaScript loads. This caused ATH tests to
time out because clickLink('Build Now') couldn't find the hidden
element.

This fix adds waitFor(by.link('Build Now')) before clicking, which
polls until the element is visible (with ATH's default 120s timeout).

Fixes timeouts in:
- core.FreestyleJobTest.doNotDiscardSuccessfulBuilds
- core.FreestyleJobTest.archiveArtifacts
- core.TriggerRemoteBuildsTest.triggerBuildRemotely
@LakshyaBagani LakshyaBagani requested a review from a team as a code owner January 20, 2026 20:49
Comment on lines +365 to +366
// Wait for "Build Now" link to become visible (JS shows it after page load)
waitFor(by.link("Build Now"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this fixes the issue, as this is looking for a a element with the text Build Now and IIUC the upstream change does not change that.
In essence I think this is just wasting some CPU such that the timing changes enough that clicking the link works.

Additionally if you do need to wait and then interact with the thing you waited for then use the WebElement returned by waitFor

int nb = getJson().get("nextBuildNumber").intValue();
if (parameters.isEmpty()) {
// Wait for "Build Now" link to become visible (JS shows it after page load)
waitFor(by.link("Build Now"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that this would work, please test this in your PR in the jenkins repository using an incremental build when the tests here pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants