Can someone please help me in converting the following scripted pipeline to declarative pipeline in Jenkins
properties(
[
parameters([
string(defaultValue: 'abc,def,ghi', name: 'NAMES')
])
]
)
node {
def namesList = params.NAMES.tokenize(',')
namesList.each { name ->
stage('build'){
echo "build for ${name}"
}
stage('test'){
echo "test for ${name}"
}
stage('deploy'){
echo "deploy for ${name}"
}
}
}
Thanks in advance
I tried seaching some online options for conversion but I am not getting any useful info. I need to use the declarative pipeline for jenkins and unable to convert existing script.
The docs should help you with this. Basically, we can take this code block from the doc and fit it to your needs:
Replace the parameters with the params you have and the stages with your scripted stages. You get something like this: