How to handle services when the developers provide incorrectly in k8s I provided the script to provision a new feature environment inside k8s it will create all the configs required, namespaces, resources and whatever...
in my script, I described this param:
parameters {
text(name: 'SERVICE_LIST', defaultValue: '', description: 'Services to deploy, separated by line breaks.')}

when the developer is provisioning a new env, he will provide a list of services that he wants to enable on that environment
also in my script, I described the following piece of code which are enabling all services requested(its located inside the stage and step):
def services = replaced.split('\\n')
   services.each { SERVICE -&gt;
    sh &quot;echo turning on service ${SERVICE}&quot;
    sh &quot;yq w -i  ${DEPLOY_ENV_FOLDER}/services.yaml '${SERVICE}.enabled' true&quot;}

this is an example of a services file:

so, when the developer provides the services that he wants, the script goes to this file, enable the services and apply to k8s
now my question is how to assure that the services provided by the developer are correct and that they exist in the file? otherwise, I need to abort the script. I tried to use try{} catch{} in the second piece of code above to define the exception for abort services which are provided by developers incorrectly, do you have any other solution?
@Mkash, don't you know in advance what services you have in your services.yaml file?
Maintain a list in groovy, and see whether the input is in that list or not.
Something like:
availableServices = [&quot;ew_ws_gateway&quot;, &quot;ingress&quot;]

services = [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;ew_ws_gateway&quot;]

services.each { svc -&gt;
    if (svc in availableServices) {
        println(&quot;Service exist&quot; + svc)
    }
}

The other option is to change the parameter from type of text to multiple-choice possibly using https://plugins.jenkins.io/extended-choice-parameter/