diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 00000000..66f94b23
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,10 @@
+/*
+ See the documentation for more options:
+ https://github.com/jenkins-infra/pipeline-library/
+*/
+buildPlugin(
+ useContainerAgent: true,
+ configurations: [
+ [platform: 'linux', jdk: 11],
+ [platform: 'windows', jdk: 11],
+])
diff --git a/pom.xml b/pom.xml
index cea6de33..7205d6c0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,7 +17,6 @@
1.1.0
999999-SNAPSHOT
2.387.2
- 11
INFO
@@ -40,9 +39,9 @@
scm:git:https://github.com/jenkinsci/${project.artifactId}-plugin.git
- scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git
- https://github.com/jenkinsci/${project.artifactId}-plugin
- HEAD
+ scm:git:https://github.com/jenkinsci/${project.artifactId}-plugin.git
+ https://github.com/jenkinsci/${project.artifactId}-plugin/
+ ${scmTag}
@@ -153,7 +152,7 @@
generate
- Messages.properties
+ FileLocations.properties
target/generated-sources/localizer
diff --git a/src/main/java/com/openshift/jenkins/plugins/OpenShift.java b/src/main/java/com/openshift/jenkins/plugins/OpenShift.java
index b9741ee0..c9bf2de6 100644
--- a/src/main/java/com/openshift/jenkins/plugins/OpenShift.java
+++ b/src/main/java/com/openshift/jenkins/plugins/OpenShift.java
@@ -18,17 +18,12 @@ public class OpenShift extends AbstractDescribableImpl {
@Extension
public static class DescriptorImpl extends Descriptor {
-
- // Store a config version so we're able to migrate config.
- public Long configVersion;
-
public List clusterConfigs;
public String ocTool = "oc"; // TODO: Make this configurable for
// kubectl?
public DescriptorImpl() {
- configVersion = 1L;
load();
}
diff --git a/src/main/java/com/openshift/jenkins/plugins/freestyle/BaseStep.java b/src/main/java/com/openshift/jenkins/plugins/freestyle/BaseStep.java
index 64e38904..82d64f73 100644
--- a/src/main/java/com/openshift/jenkins/plugins/freestyle/BaseStep.java
+++ b/src/main/java/com/openshift/jenkins/plugins/freestyle/BaseStep.java
@@ -33,10 +33,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
+import java.util.*;
import static com.openshift.jenkins.plugins.util.ClientCommandOutputCleaner.redactSensitiveData;
@@ -44,10 +41,6 @@ public abstract class BaseStep extends Builder {
public static final String DEFAULT_LOGLEVEL = "0";
- public static final String SERVICE_ACCOUNT_NAMESPACE_PATH = "/var/run/secrets/kubernetes.io/serviceaccount/namespace";
- public static final String SERVICE_ACCOUNT_TOKEN_PATH = "/var/run/secrets/kubernetes.io/serviceaccount/token";
- public static final String SERVICE_ACCOUNT_CA_PATH = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt";
-
private String clusterName;
private String project;
@@ -147,6 +140,8 @@ protected boolean runOcCommand(final AbstractBuild build,
ArrayList advArgs = new ArrayList();
+ ResourceBundle bundle = ResourceBundle.getBundle("io.fabric8.jenkins.plugins.FileLocations");
+
if (advancedArguments != null) {
for (AdvancedArgument advArg : advancedArguments) {
advArgs.add(advArg.getValue(overrides));
@@ -156,6 +151,7 @@ protected boolean runOcCommand(final AbstractBuild build,
if (c == null) { // if null, we assume the cluster is running the
// Jenkins node.
server = ClusterConfig.getHostClusterApiServerUrl();
+ String SERVICE_ACCOUNT_CA_PATH = bundle.getString("SERVICE_ACCOUNT_CA_PATH");
selectedCAPath = SERVICE_ACCOUNT_CA_PATH;
caContent = null;
} else {
@@ -178,6 +174,7 @@ protected boolean runOcCommand(final AbstractBuild build,
+ getClusterName(overrides));
}
} else {
+ String SERVICE_ACCOUNT_NAMESPACE_PATH = bundle.getString("SERVICE_ACCOUNT_NAMESPACE_PATH");
project = new String(Files.readAllBytes(Paths
.get(SERVICE_ACCOUNT_NAMESPACE_PATH)),
StandardCharsets.UTF_8);
@@ -213,6 +210,7 @@ protected boolean runOcCommand(final AbstractBuild build,
}
token = tokenSecret.getToken();
} else {
+ String SERVICE_ACCOUNT_TOKEN_PATH = bundle.getString("SERVICE_ACCOUNT_TOKEN_PATH");
// We are running within a host cluster, so use mounted secret
token = new String(Files.readAllBytes(Paths
.get(SERVICE_ACCOUNT_TOKEN_PATH)), StandardCharsets.UTF_8);
@@ -261,7 +259,7 @@ public boolean perform(ProcessBuilder pb)
@Override
public void run() {
StringBuffer sb = new StringBuffer();
- try (Reader reader = new InputStreamReader(output)) {
+ try (Reader reader = new InputStreamReader(output, StandardCharsets.UTF_8)) {
LineIterator it = IOUtils.lineIterator(reader);
while (it.hasNext()) {
String line = it.nextLine();
@@ -348,7 +346,7 @@ public static String getOverride(String key, Map overrides) {
// try override when the key is the entire parameter ... we don't just
// use
// replaceMacro cause we also support PARM with $ or ${}
- if (overrides != null && overrides.containsKey(val)) {
+ if (overrides.containsKey(val)) {
val = overrides.get(val);
} else {
// see if it is a mix used key (i.e. myapp-${VERSION}) or ${val}
diff --git a/src/main/java/com/openshift/jenkins/plugins/pipeline/OcAction.java b/src/main/java/com/openshift/jenkins/plugins/pipeline/OcAction.java
index 7f1c335e..0bba0f00 100644
--- a/src/main/java/com/openshift/jenkins/plugins/pipeline/OcAction.java
+++ b/src/main/java/com/openshift/jenkins/plugins/pipeline/OcAction.java
@@ -161,7 +161,7 @@ private void printToConsole(String line) {
@Override
protected OcActionResult run() throws IOException, InterruptedException, ExecutionException {
- if (filePath != null && !filePath.exists()) {
+ if (!filePath.exists()) {
filePath.mkdirs();
}
diff --git a/src/main/java/com/openshift/jenkins/plugins/pipeline/OcWatch.java b/src/main/java/com/openshift/jenkins/plugins/pipeline/OcWatch.java
index 033c4a92..c4ac4d2f 100644
--- a/src/main/java/com/openshift/jenkins/plugins/pipeline/OcWatch.java
+++ b/src/main/java/com/openshift/jenkins/plugins/pipeline/OcWatch.java
@@ -94,7 +94,7 @@ public static final class Execution extends AbstractSynchronousNonBlockingStepEx
private transient TaskListener listener;
public Void run() throws IOException, InterruptedException {
- if (filePath != null && !filePath.exists()) {
+ if (!filePath.exists()) {
filePath.mkdirs();
}
getContext().saveState();
@@ -145,7 +145,7 @@ public Void run() throws IOException, InterruptedException {
if (t.getCause() != null) {
exceptionMsgs = exceptionMsgs + "; " + t.getCause().getMessage();
}
- listener.getLogger().println(String.format("\nwatch closure threw an exception: \"%s\".\n", exceptionMsgs));
+ listener.getLogger().println(String.format("%nwatch closure threw an exception: \"%s\".%n", exceptionMsgs));
throw new IOException(t);
}
}
diff --git a/src/main/java/com/openshift/jenkins/plugins/util/ClientCommandBuilder.java b/src/main/java/com/openshift/jenkins/plugins/util/ClientCommandBuilder.java
index 52a1708c..d6818ad4 100644
--- a/src/main/java/com/openshift/jenkins/plugins/util/ClientCommandBuilder.java
+++ b/src/main/java/com/openshift/jenkins/plugins/util/ClientCommandBuilder.java
@@ -41,7 +41,7 @@ public static enum OsType {
DARWIN, UNIX, WINDOWS, ZOS
}
- public static final class getOsType extends MasterToSlaveCallable {
+ public static final class GetOsType extends MasterToSlaveCallable {
@Override
public OsType call() throws RuntimeException {
return getOsFromPlatform();
@@ -80,9 +80,9 @@ public static String[] fixPathInCommandArray(String[] command, EnvVars envVars,
* var and do 1)
*/
- OsType targetType = filePath.act(new getOsType());
+ OsType targetType = filePath.act(new GetOsType());
String path = envVars.get("PATH");
- List foundOcs = new ArrayList();
+ List foundOcs;
FindOC finder = new FindOC(path);
try {
foundOcs = filePath.act(finder);
@@ -90,14 +90,11 @@ public static String[] fixPathInCommandArray(String[] command, EnvVars envVars,
t.printStackTrace(listener.getLogger());
return command;
}
- if (foundOcs == null || foundOcs.size() == 0) {
+ if (foundOcs.size() == 0) {
if (verbose)
listener.getLogger()
.println("could not find oc binary on the target computer of OS type " + targetType);
- if (!(launcher instanceof RemoteLauncher) || !(launcher instanceof LocalLauncher)) {
- if (verbose)
- listener.getLogger().println("but your launcher is of a type that might have hindered out scan");
- }
+
} else {
if (verbose)
listener.getLogger().println("found the following oc executables on the target computer of OS type "
@@ -158,7 +155,7 @@ private List toStringArray(List list) {
ArrayList listCopy = new ArrayList(list);
for (int i = 0; i < listCopy.size(); i++) {
String element = listCopy.get(i);
- if (element != null && element.trim().length() == 0) {
+ if ( element.trim().length() == 0) {
// skip entry presumably blanked by our -f processing below
continue;
}
diff --git a/src/main/java/com/openshift/jenkins/plugins/util/ClientCommandRunner.java b/src/main/java/com/openshift/jenkins/plugins/util/ClientCommandRunner.java
index 8e92f1e9..85ce16c1 100644
--- a/src/main/java/com/openshift/jenkins/plugins/util/ClientCommandRunner.java
+++ b/src/main/java/com/openshift/jenkins/plugins/util/ClientCommandRunner.java
@@ -1,5 +1,6 @@
package com.openshift.jenkins.plugins.util;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.EnvVars;
import hudson.FilePath;
import hudson.Launcher;
@@ -11,6 +12,7 @@
import javax.annotation.Nonnull;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -21,6 +23,7 @@
/***
* {@link ClientCommandRunner} runs `oc` on a slave
*/
+@SuppressFBWarnings("SE_BAD_FIELD")
public class ClientCommandRunner implements Serializable {
private static final long serialVersionUID = 42L;
private static final Logger LOGGER = Logger.getLogger(ClientCommandRunner.class.getName());
@@ -75,6 +78,7 @@ public ClientCommandRunner(@Nonnull String[] command, @Nonnull FilePath filePath
this.stderrOutputObserver = stderrOutputObserver;
}
+
private static class OcOutputConsumer implements Callable