Skip to content

Commit

Permalink
Miscellaneous code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Feb 5, 2025
1 parent b5b2fb4 commit be16066
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 59 deletions.
4 changes: 1 addition & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ for (int i = 0; i < splits.size(); i++) {
if (jdk != 21 && jenkinsVersion == 'latest') {
return
}
// TODO enable on LTS line when it is based on 2.480 or later
def cspRule = jenkinsVersion == 'latest'
def name = "${jenkinsVersion}-${platform}-jdk${jdk}-${browser}-split${index}"
branches[name] = {
stage(name) {
Expand Down Expand Up @@ -149,7 +147,7 @@ for (int i = 0; i < splits.size(); i++) {
eval \$(vnc.sh)
java -version
mvn -v
run.sh ${browser} ${jenkinsVersion} -Dmaven.repo.local=${WORKSPACE_TMP}/m2repo -Dmaven.test.failure.ignore=true -Dcsp.rule=${cspRule} -DforkCount=1 -B
run.sh ${browser} ${jenkinsVersion} -Dmaven.repo.local=${WORKSPACE_TMP}/m2repo -Dmaven.test.failure.ignore=true -Dcsp.rule -DforkCount=1 -B
cp --verbose target/surefire-reports/TEST-*.xml /reports
"""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@
*/
package org.jenkinsci.test.acceptance.plugins.scriptler;

import java.util.List;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jenkinsci.test.acceptance.po.Jenkins;
import org.jenkinsci.test.acceptance.po.Node;

public class ScriptResult {
private static final List<String> BUILT_IN_NODE_NAMES = List.of("built-in", "controller", "master");
private final String result;

public ScriptResult(String result) {
Expand All @@ -41,14 +38,7 @@ public ScriptResult(String result) {
public String output(Node node) {
String name = node.getName();
if (node instanceof Jenkins) {
// TODO: use the below code once Scriptler versions 390 and up are the only ones tested
// return "(" + node + ")";
return BUILT_IN_NODE_NAMES.stream()
.map(nodeName -> "(" + nodeName + ")")
.map(this::output)
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
return "(" + node + ")";
}
return output(name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static org.junit.Assert.assertTrue;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import hudson.util.VersionNumber;
import java.time.Duration;
import org.jenkinsci.test.acceptance.plugins.credentials.UserPwdCredential;
import org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshCredentialDialog;
Expand All @@ -13,7 +12,6 @@
import org.jenkinsci.test.acceptance.po.Describable;
import org.jenkinsci.test.acceptance.po.PageObject;
import org.jenkinsci.test.acceptance.selenium.UselessFileDetectorReplacement;
import org.openqa.selenium.By;

/**
* @author Kohsuke Kawaguchi
Expand All @@ -37,29 +35,9 @@ public SshSlaveLauncher(PageObject context, String path) {
public SshCredentialDialog addCredential() {
find(by.button("Add")).click();

if (getElement(By.cssSelector(".credentials-add-menu-items")) != null) {
/*
* This condition is for backwards compatibility and can be removed when we drop support for Credentials
* 1381 and earlier.
*/
String providerXpathExpr = "//div[contains(@class,'credentials-add-menu-items')]"
+ "/div[@class='bd']/ul[@class='first-of-type']/li[contains(@class, 'yuimenuitem')]"
+ "/span[contains(@class,'yuimenuitemlabel') and contains(@tooltip, 'Jenkins Credentials Provider')]";
waitFor(by.xpath(providerXpathExpr)).click();
} else if (getPage().getJenkins().getVersion().isOlderThan(new VersionNumber("2.480"))) {
/*
* This condition is for backwards compatibility and can be removed when we drop support for 2.479 and
* earlier.
*/
all(by.css(".jenkins-dropdown"))
.get(1)
.findElement(by.button("Jenkins Credentials Provider"))
.click();
} else {
find(by.css(".jenkins-dropdown"))
.findElement(by.button("Jenkins Credentials Provider"))
.click();
}
find(by.css(".jenkins-dropdown"))
.findElement(by.button("Jenkins Credentials Provider"))
.click();

return new SshCredentialDialog(getPage(), "/credentials");
}
Expand Down
25 changes: 5 additions & 20 deletions src/main/java/org/jenkinsci/test/acceptance/po/LabelAxis.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jenkinsci.test.acceptance.po;

import java.time.Duration;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;

/**
Expand All @@ -17,25 +16,11 @@ public void select(String name) {
WebElement checkBox =
find(by.path(getPath())).findElement(by.xpath(".//input[@name='values' and @json='%s']", name));
if (!checkBox.isDisplayed()) {
try {
// unfold the labels and slaves sub-nodes
find(by.xpath("(//button[@class='jenkins-button mp-label-axis__button'])[1]"))
.click();
find(by.xpath("(//button[@class='jenkins-button mp-label-axis__button'])[2]"))
.click();
} catch (NoSuchElementException e) {
// forward compatibility
}

try {
// unfold the labels and slaves sub-nodes
find(by.xpath("//div[@class='yahooTree labelAxis-tree']//table[@id='ygtvtableel1']//a"))
.click();
find(by.xpath("//div[@class='yahooTree labelAxis-tree']//table[@id='ygtvtableel2']//a"))
.click();
} catch (NoSuchElementException e) {
// backward compatibility
}
// unfold the labels and slaves sub-nodes
find(by.xpath("(//button[@class='jenkins-button mp-label-axis__button'])[1]"))
.click();
find(by.xpath("(//button[@class='jenkins-button mp-label-axis__button'])[2]"))
.click();

waitFor().withTimeout(Duration.ofSeconds(3)).until(checkBox::isDisplayed);
}
Expand Down

0 comments on commit be16066

Please # to comment.