Skip to content

Commit

Permalink
update dependencies and fix error with CredentialsUtils.java
Browse files Browse the repository at this point in the history
  • Loading branch information
prdhamdh committed Oct 22, 2024
1 parent c571f7e commit 38feaf5
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 80 deletions.
63 changes: 17 additions & 46 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.440.x</artifactId>
<version>3387.v0f2773fa_3200</version>
<version>3435.v238d66a_043fb_</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand All @@ -127,60 +127,31 @@
<artifactId>joda-time</artifactId>
<version>2.12.5</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-multibranch</artifactId>
<version>773.vc4fe1378f1d5</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>865.v43e78cc44e0d</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>3832.vc43e04d6d68c</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<version>1289.v4d3e7b_01546b_</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>1283.v99c10937efcb_</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.pipeline-stage-view</groupId>
<artifactId>pipeline-rest-api</artifactId>
<version>2.34</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git</artifactId>
<version>5.2.1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>branch-api</artifactId>
<version>2.1128.v717130d4f816</version>
</dependency>
<dependency>
<groupId>io.jenkins.blueocean</groupId>
<artifactId>blueocean-rest</artifactId>
<version>1.27.9</version>
<version>1.27.16</version>
</dependency>
<dependency>
<groupId>org.csanchez.jenkins.plugins</groupId>
<artifactId>kubernetes</artifactId>
<version>4174.v4230d0ccd951</version>
<version>4290.v93ea_4b_b_26a_61</version>
</dependency>
<!-- Downgrade asm-api version from 9.7-33.x to 9.6-3.x to resolve compatibility issues with asm-util -->
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>asm-api</artifactId>
<version>9.6-3.v2e1fa_b_338cd7</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.16.1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>scm-api</artifactId>
<version>676.v886669a_199a_a_</version>
<groupId>io.jenkins.plugins.mina-sshd-api</groupId>
<artifactId>mina-sshd-api-common</artifactId>
<version>2.14.0-131.v04e9b_6b_e0362</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import hudson.model.Descriptor.FormException;
import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.client.informers.ResourceEventHandler;
import io.fabric8.kubernetes.client.informers.SharedIndexInformer;
Expand Down Expand Up @@ -88,8 +89,7 @@ public void onAdd(Build obj) {
LOGGER.info("Build informer received add event for: " + name);
try {
addEventToJenkinsJobRun(obj);
} catch (IOException e) {
// TODO Auto-generated catch block
} catch (IOException | FormException e) {
e.printStackTrace();
}
}
Expand All @@ -106,7 +106,11 @@ public void onUpdate(Build oldObj, Build newObj) {
String oldRv = oldObj.getMetadata().getResourceVersion();
String newRv = newObj.getMetadata().getResourceVersion();
LOGGER.info("Build informer received update event for: " + oldRv + " to: " + newRv);
modifyEventToJenkinsJobRun(newObj);
try {
modifyEventToJenkinsJobRun(newObj);
} catch (FormException e) {
e.printStackTrace();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import hudson.model.Descriptor.FormException;
import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.client.informers.ResourceEventHandler;
import io.fabric8.kubernetes.client.informers.SharedIndexInformer;
Expand All @@ -53,7 +54,7 @@ public int getListIntervalInSeconds() {
return 1_000 * GlobalPluginConfiguration.get().getBuildConfigListInterval();
}

public void start() {
public void start() throws FormException {
LOGGER.info("Starting BuildConfig informer for " + namespaces + "!!");
LOGGER.debug("listing BuildConfig resources");
SharedInformerFactory factory = getInformerFactory();
Expand Down Expand Up @@ -86,7 +87,6 @@ public void onAdd(BuildConfig obj) {
try {
upsertJob(obj);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Expand All @@ -106,7 +106,6 @@ public void onUpdate(BuildConfig oldObj, BuildConfig newObj) {
try {
modifyEventToJenkinsJob(newObj);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Expand All @@ -123,7 +122,6 @@ public void onDelete(BuildConfig obj, boolean deletedFinalStateUnknown) {
try {
deleteEventToJenkinsJob(obj);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.multibranch.BranchJobProperty;

import hudson.model.Descriptor.FormException;
import hudson.plugins.git.BranchSpec;
import hudson.plugins.git.GitSCM;
import hudson.plugins.git.SubmoduleConfig;
Expand All @@ -59,8 +60,9 @@ public class BuildConfigToJobMapper {
* @param bc A BuildConfig object.
* @return the FlowDefinition representing a Jenkins Build built from a
* pipeline.
* @throws FormException
*/
public static FlowDefinition mapBuildConfigToFlow(BuildConfig bc) throws IOException {
public static FlowDefinition mapBuildConfigToFlow(BuildConfig bc) throws IOException, FormException {
if (!OpenShiftUtils.isPipelineStrategyBuildConfig(bc)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import hudson.model.Descriptor.FormException;
import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.client.informers.ResourceEventHandler;
import io.fabric8.kubernetes.client.informers.SharedIndexInformer;
Expand Down Expand Up @@ -83,8 +84,7 @@ public void onAdd(Build obj) {
LOGGER.info(String.format("Build informer received add event for: %s", name));
try {
addEventToJenkinsJobRun(obj);
} catch (IOException e) {
// TODO Auto-generated catch block
} catch (IOException | FormException e) {
e.printStackTrace();
}
}
Expand All @@ -97,7 +97,11 @@ public void onUpdate(Build oldObj, Build newObj) {
String oldRv = oldObj.getMetadata().getResourceVersion();
String newRv = newObj.getMetadata().getResourceVersion();
LOGGER.info(String.format("Build informer received update event for: %s to: %s", oldRv,newRv));
modifyEventToJenkinsJobRun(newObj);
try {
modifyEventToJenkinsJobRun(newObj);
} catch (FormException e) {
e.printStackTrace();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;

import hudson.model.Descriptor.FormException;
import hudson.security.ACL;
import io.fabric8.kubernetes.api.model.OwnerReference;
import io.fabric8.openshift.api.model.Build;
Expand Down Expand Up @@ -76,7 +77,7 @@ public class BuildManager {
*/
protected static final ConcurrentHashMap<String, Build> buildsWithNoBCList = new ConcurrentHashMap<String, Build>();

public static void onInitialBuilds(BuildList buildList) {
public static void onInitialBuilds(BuildList buildList) throws FormException {
if (buildList == null)
return;
List<Build> items = buildList.getItems();
Expand Down Expand Up @@ -177,7 +178,7 @@ public int compare(Build b1, Build b2) {
}
}

static void modifyEventToJenkinsJobRun(Build build) {
static void modifyEventToJenkinsJobRun(Build build) throws FormException {
BuildStatus status = build.getStatus();
if (status != null && isCancellable(status) && isCancelled(status)) {
WorkflowJob job = getJobFromBuild(build);
Expand All @@ -192,7 +193,7 @@ static void modifyEventToJenkinsJobRun(Build build) {
}
}

public static boolean addEventToJenkinsJobRun(Build build) throws IOException {
public static boolean addEventToJenkinsJobRun(Build build) throws IOException, FormException {
// should have been caught upstack, but just in case since public method
if (!OpenShiftUtils.isPipelineStrategyBuild(build))
return false;
Expand Down Expand Up @@ -233,7 +234,7 @@ static void removeBuildFromNoBCList(Build build) {

// trigger any builds whose watch events arrived before the
// corresponding build config watch events
public static void flushBuildsWithNoBCList() {
public static void flushBuildsWithNoBCList() throws FormException {

ConcurrentHashMap<String, Build> clone;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import hudson.model.Result;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.model.Descriptor.FormException;
import hudson.model.listeners.RunListener;
import hudson.triggers.SafeTimerTask;
import io.fabric8.kubernetes.client.KubernetesClientException;
Expand Down Expand Up @@ -182,7 +183,11 @@ public void onCompleted(Run run, @Nonnull TaskListener listener) {
runsToPoll.remove(run);
boolean updated = pollRun(run);
logger.info("onCompleted " + run.getUrl() + "updated: " + updated);
maybeScheduleNext(((WorkflowRun) run).getParent());
try {
maybeScheduleNext(((WorkflowRun) run).getParent());
} catch (FormException e) {
e.printStackTrace();
}
}
super.onCompleted(run, listener);
}
Expand All @@ -193,7 +198,11 @@ public void onDeleted(Run run) {
runsToPoll.remove(run);
boolean updated = pollRun(run);
logger.info("onDeleted " + run.getUrl() + "updated: " + updated);
maybeScheduleNext(((WorkflowRun) run).getParent());
try {
maybeScheduleNext(((WorkflowRun) run).getParent());
} catch (FormException e) {
e.printStackTrace();
}
}
super.onDeleted(run);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;

import hudson.model.Fingerprint;
import hudson.model.Descriptor.FormException;
import hudson.security.ACL;
import io.fabric8.kubernetes.api.model.LocalObjectReference;
import io.fabric8.kubernetes.api.model.ObjectMeta;
Expand Down Expand Up @@ -101,7 +102,7 @@ public static Secret getSourceSecretForBuildConfig(BuildConfig buildConfig) {
return null;
}

public static String updateSourceCredentials(BuildConfig buildConfig) throws IOException {
public static String updateSourceCredentials(BuildConfig buildConfig) throws IOException, FormException {
String credentialsName = null;
Secret sourceSecret = getSourceSecretForBuildConfig(buildConfig);
if (sourceSecret != null) {
Expand Down Expand Up @@ -171,8 +172,9 @@ private static String getSecretCustomName(Secret secret) {
* @param secret the secret to insert
* @return the insert secret name
* @throws IOException when the update of the secret fails
* @throws FormException
*/
public static String upsertCredential(Secret secret) throws IOException {
public static String upsertCredential(Secret secret) throws IOException, FormException {
if (secret != null) {
ObjectMeta metadata = secret.getMetadata();
if (metadata != null) {
Expand All @@ -182,7 +184,7 @@ public static String upsertCredential(Secret secret) throws IOException {
return null;
}

private static String insertOrUpdateCredentialsFromSecret(Secret secret) throws IOException {
private static String insertOrUpdateCredentialsFromSecret(Secret secret) throws IOException, FormException {
if (secret != null) {
String customSecretName = getSecretCustomName(secret);
ObjectMeta metadata = secret.getMetadata();
Expand Down Expand Up @@ -355,7 +357,7 @@ private static Credentials arbitraryKeyValueTextCredential(Map<String, String> d
new String(Base64.getEncoder().encode(text.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8));
}

private static Credentials secretToCredentials(Secret secret) {
private static Credentials secretToCredentials(Secret secret) throws FormException {
String namespace = secret.getMetadata().getNamespace();
String name = secret.getMetadata().getName();
Map<String, String> data = secret.getData();
Expand Down Expand Up @@ -473,7 +475,7 @@ private static Credentials newSSHUserCredential(String secretName, String userna
}

private static Credentials newUsernamePasswordCredentials(String secretName, String usernameData,
String passwordData) {
String passwordData) throws FormException {
if (secretName == null || secretName.length() == 0 || usernameData == null || usernameData.length() == 0
|| passwordData == null || passwordData.length() == 0) {
logger.log(WARNING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.logging.Logger;

import hudson.init.InitMilestone;
import hudson.model.Descriptor.FormException;
import hudson.triggers.SafeTimerTask;
import jenkins.model.Jenkins;

Expand All @@ -29,7 +30,7 @@ protected void doRun() throws Exception {
start();
}

private void start() {
private void start() throws FormException {
if (GlobalPluginConfiguration.get().isUseClusterMode()) {
startClusterInformers();
logger.info("All the cluster informers have been registered!! ... starting all registered informers");
Expand Down Expand Up @@ -92,7 +93,7 @@ private void startNamespaceInformers() {
}
}

private void startClusterInformers() {
private void startClusterInformers() throws FormException {
logger.info("Initializing cluster informers ...");
GlobalPluginConfiguration configuration = GlobalPluginConfiguration.get();
if (configuration.isSyncBuildConfigsAndBuilds()) {
Expand Down
Loading

0 comments on commit 38feaf5

Please sign in to comment.