def git_url = 'https://github.com/initedit/simple-storage-solution.git'
def git_branch = 'master'
pipeline
{
agent
{
label 'master'
}
stages
{
stage('skip1')
{
when {
expression {
echo git_branch
isDev = !(git_branch =~ /^dev*([a-zA-Z0-9]*)/)
return isDev
}
}
steps{
echo "if dev branch it will skip"
}
}
}
}
Regex:
^dev*([a-zA-Z0-9]* = Start with dev
dev*([a-zA-Z0-9]* = contains dev
More : https://e.printstacktrace.blog/groovy-regular-expressions-the-definitive-guide/