Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add job name validation #87

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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