I have Bitbucket repository. There are multiple directory. I am using Jenkins parametrized job to build the each micro-services. There are two string parameter using one for services and second for environment. I want to validate services name which i passed in the string paramter before executing the stage of that particular micr-service.
Like folder structure is: service-one service-two service-three
if someone using wrong service name like services_one, service--one, serviceone then stage will not execute.
currently, I am passing two string paramters. Fist: Name: services Value: service-one, service-two, service-three
Second: Name: environment Value: Dev
node{
env.SERVICE_NAMES = params.services
env.ENVIRONMENT = params.environment
stage('clone'){
git branch: 'main', credentialsId: 'repo-login', url: 'https://repo-urk/project/mutiple-servcies.git'
}
// Mulitple stages loop for services
"${env.SERVICE_NAMES}".split(",").each { param ->
service_name = "$param".trim()
stage("${service_name}"){
println "Stage executed for: ${service_name}"
}
}
}
You can use
fileExistslike this: