Skip to content

Commit

Permalink
Add job name validation (#87)
Browse files Browse the repository at this point in the history
* add jobName validation

Signed-off-by: Anatoli Kalbasin <[email protected]>

* delete testing mark

Signed-off-by: Anatoli Kalbasin <[email protected]>

---------

Signed-off-by: Anatoli Kalbasin <[email protected]>
  • Loading branch information
callbacksin authored Oct 22, 2024
1 parent 663d4ca commit 9bc076b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
20 changes: 19 additions & 1 deletion src/main/kotlin/org/zowe/zdevops/classic/steps/SubmitJobStep.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/*
* Copyright (c) 2024 IBA Group.
*
* 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 2022
* Contributors:
* IBA Group
* Zowe Community
*/

package org.zowe.zdevops.classic.steps
Expand All @@ -15,12 +19,15 @@ import hudson.Extension
import hudson.Launcher
import hudson.model.AbstractBuild
import hudson.model.BuildListener
import hudson.util.FormValidation
import org.kohsuke.stapler.DataBoundConstructor
import org.kohsuke.stapler.QueryParameter
import org.kohsuke.stapler.bind.JavaScriptMethod
import org.zowe.zdevops.Messages
import org.zowe.zdevops.classic.AbstractBuildStep
import org.zowe.zdevops.logic.submitJob
import org.zowe.zdevops.logic.submitJobSync
import org.zowe.zdevops.utils.validateFieldIsNotEmpty

class SubmitJobStep
@DataBoundConstructor
Expand Down Expand Up @@ -66,5 +73,16 @@ constructor(
fun createStepId(): String {
return marker + lastStepId++.toString()
}

/**
* Performs form validation for the 'jobName' parameter to ensure it is not empty.
*
* @param jobName job to run
* @return A {@link FormValidation} object indicating whether the field is valid or contains an error.
*/
fun doCheckJobName(@QueryParameter jobName: String): FormValidation? {
return validateFieldIsNotEmpty(jobName)
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<jelly:jelly xmlns:jelly="jelly:core" xmlns:form="/lib/form" xmlns:stapler="jelly:stapler">

<jelly:set var="stepId" value="${descriptor.createStepId()}" />
<p>${stepId}</p>

<form:entry field="connectionName" title="${%zdevops.classic.connection.title}">
<form:select/>
Expand Down

0 comments on commit 9bc076b

Please sign in to comment.