diff --git a/README.md b/README.md
index 16aa3b4..fa8a0c6 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Zowe zDevOps Jenkins plugin
-## About the plugin
+## About the plugin
The Zowe zDevOps Jenkins Plugin by [IBA Group](https://ibagroupit.com/?utm_campaign=IBA_W-Mainframe&utm_source=jenkins&utm_medium=referral&utm_content=description_zdevops) is an open-source, secure , and reliable agent-less Jenkins plugin that makes it possible to perform most of the actual tasks on the mainframe, managing it with a modern native mainframe zOSMF REST API and the capabilities of available zOSMF SDKs.
## Advantages
diff --git a/pom.xml b/pom.xml
index f507f17..2a9f4d9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
org.jenkins-ci.plugins
plugin
- 4.78
+ 4.78
@@ -19,7 +19,7 @@
- 0.2.0-
+ 0.2.0
-SNAPSHOT
2.414.3
17
@@ -375,22 +375,12 @@
2.10.1
-
- org.jenkins-ci.plugins
- script-security
-
-
org.apache.commons
commons-lang3
3.12.0
-
- org.jenkins-ci
- annotation-indexer
-
-
com.squareup.okhttp3
okhttp
@@ -439,6 +429,28 @@
test
+
+
+
+ org.jenkins-ci
+ annotation-indexer
+
+
+
+ org.jenkins-ci.plugins
+ script-security
+
+
+
+ org.jenkins-ci.plugins
+ credentials
+
+
+
+ org.jenkins-ci.plugins.workflow
+ workflow-step-api
+
+
diff --git a/src/main/kotlin/org/zowe/zdevops/classic/AbstractBuildStep.kt b/src/main/kotlin/org/zowe/zdevops/classic/AbstractBuildStep.kt
index c64cca0..6aecdba 100644
--- a/src/main/kotlin/org/zowe/zdevops/classic/AbstractBuildStep.kt
+++ b/src/main/kotlin/org/zowe/zdevops/classic/AbstractBuildStep.kt
@@ -24,6 +24,7 @@ import org.kohsuke.stapler.QueryParameter
import org.zowe.kotlinsdk.zowe.client.sdk.core.ZOSConnection
import org.zowe.zdevops.Messages
import org.zowe.zdevops.config.ZOSConnectionList
+import org.zowe.zdevops.utils.validateConnection
import java.io.IOException
import java.io.PrintWriter
import java.io.StringWriter
@@ -71,6 +72,8 @@ abstract class AbstractBuildStep(val connectionName: String) : Builder(), Simple
connURL.host, connURL.port.toString(), connection.username, connection.password, connURL.protocol
)
+ validateConnection(zosConnection)
+
perform(build, launcher, listener, zosConnection)
return true
}
diff --git a/src/main/kotlin/org/zowe/zdevops/config/ZOSConnection.kt b/src/main/kotlin/org/zowe/zdevops/config/ZOSConnection.kt
index 75b68aa..e81e35d 100644
--- a/src/main/kotlin/org/zowe/zdevops/config/ZOSConnection.kt
+++ b/src/main/kotlin/org/zowe/zdevops/config/ZOSConnection.kt
@@ -16,10 +16,6 @@ import com.cloudbees.plugins.credentials.common.StandardCredentials
import com.cloudbees.plugins.credentials.common.StandardListBoxModel
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials
import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder
-import org.zowe.kotlinsdk.zowe.client.sdk.zosfiles.ZosDsnList
-import org.zowe.kotlinsdk.zowe.client.sdk.zosfiles.input.ListParams
-import org.zowe.zdevops.Messages
-import org.zowe.zdevops.declarative.jobs.zMessages
import hudson.Extension
import hudson.model.AbstractDescribableImpl
import hudson.model.Descriptor
@@ -32,6 +28,9 @@ import net.sf.json.JSONObject
import org.kohsuke.stapler.DataBoundConstructor
import org.kohsuke.stapler.QueryParameter
import org.kohsuke.stapler.StaplerRequest
+import org.zowe.zdevops.Messages
+import org.zowe.zdevops.declarative.jobs.zMessages
+import org.zowe.zdevops.utils.getTestDatasetList
import java.io.IOException
import java.io.ObjectInputStream
import java.io.ObjectOutputStream
@@ -119,9 +118,9 @@ constructor(
val testConnection = org.zowe.kotlinsdk.zowe.client.sdk.core.ZOSConnection(
connURL.host, connURL.port.toString(), credentials.username, credentials.password.plainText, connURL.protocol
)
- ZosDsnList(testConnection).listDsn(zMessages.zdevops_config_ZOSConnection_validation_testDS(), ListParams())
+ getTestDatasetList(testConnection)
}.onFailure {
- return FormValidation.error(zMessages.zdevops_config_ZOSConnection_validation_error());
+ return FormValidation.error("${zMessages.zdevops_config_ZOSConnection_validation_error()}\n(${it.message})");
}
return FormValidation.ok(zMessages.zdevops_config_ZOSConnection_validation_success())
}
diff --git a/src/main/kotlin/org/zowe/zdevops/declarative/AbstractZosmfAction.kt b/src/main/kotlin/org/zowe/zdevops/declarative/AbstractZosmfAction.kt
index 5cf4b4e..7537d69 100644
--- a/src/main/kotlin/org/zowe/zdevops/declarative/AbstractZosmfAction.kt
+++ b/src/main/kotlin/org/zowe/zdevops/declarative/AbstractZosmfAction.kt
@@ -23,6 +23,7 @@ import jenkins.tasks.SimpleBuildStep
import org.zowe.kotlinsdk.zowe.client.sdk.core.ZOSConnection
import org.zowe.zdevops.Messages
import org.zowe.zdevops.config.ZOSConnectionList
+import org.zowe.zdevops.utils.validateConnection
import java.io.PrintWriter
import java.io.StringWriter
import java.net.URL
@@ -50,6 +51,9 @@ abstract class AbstractZosmfAction : Builder(), SimpleBuildStep {
val zoweConnection = ZOSConnection(
connURL.host, connURL.port.toString(), connection.username, connection.password, connURL.protocol
)
+
+ validateConnection(zoweConnection)
+
runCatching {
perform(run, workspace, env, launcher, listener, zoweConnection)
}.onFailure {
diff --git a/src/main/kotlin/org/zowe/zdevops/utils/ConnectionValidation.kt b/src/main/kotlin/org/zowe/zdevops/utils/ConnectionValidation.kt
new file mode 100644
index 0000000..d5211a0
--- /dev/null
+++ b/src/main/kotlin/org/zowe/zdevops/utils/ConnectionValidation.kt
@@ -0,0 +1,42 @@
+/*
+ * This program and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v2.0 which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-v20.html
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Copyright IBA Group 2024
+ */
+
+package org.zowe.zdevops.utils
+
+import hudson.AbortException
+import org.zowe.kotlinsdk.zowe.client.sdk.core.ZOSConnection
+import org.zowe.kotlinsdk.zowe.client.sdk.zosfiles.ZosDsnList
+import org.zowe.kotlinsdk.zowe.client.sdk.zosfiles.input.ListParams
+import org.zowe.zdevops.Messages
+
+/**
+ * Gets a list of datasets
+ * Calls the listDsn function of ZosDsnList to list data set names.
+ * Passes a test data set name ('HELLO.THERE').
+ *
+ * @param zosConnection The ZOSConnection object representing the connection to the z/OS system.
+ */
+fun getTestDatasetList(zosConnection: ZOSConnection) {
+ ZosDsnList(zosConnection).listDsn(Messages.zdevops_config_ZOSConnection_validation_testDS(), ListParams())
+}
+
+/**
+ * Validates a z/OS connection.
+ *
+ * @param zosConnection The ZOSConnection object representing the connection to the z/OS system.
+ */
+fun validateConnection(zosConnection: ZOSConnection) {
+ try {
+ getTestDatasetList(zosConnection)
+ } catch (connectException: Exception) {
+ val connExMessage = "Failed to connect to z/OS (${zosConnection.user}@${zosConnection.host}:${zosConnection.zosmfPort}): ${connectException.message}"
+ throw AbortException(connExMessage)
+ }
+}
\ No newline at end of file