For the below line
ERROR: /var/lib/jenkins/workspace/example/test@script/Jenkinsfile not found
Conditions:
1.Have to start the line with ERROR
2.where example/test will change dynamically
How to achieve this through Regex
For the below line
ERROR: /var/lib/jenkins/workspace/example/test@script/Jenkinsfile not found
Conditions:
1.Have to start the line with ERROR
2.where example/test will change dynamically
How to achieve this through Regex
This is one way to do it
^ERROR: \/var\/lib\/jenkins\/workspace\/[\w+\/]*@script\/Jenkinsfile not found$
Explanation:
^ -- start of string
ERROR: \/var\/lib\/jenkins\/workspace\/ -- fixed portion of path
[\w+\/]+ -- variable portion
@script\/Jenkinsfile not found -- fixed portion of path
$ -- end of string
The capture group [\w+\/]+
captures variable strings like example/test
example
or foo/bar/baz/staging
Edit: if the variable part is always 2 words seperated by a slash you can do something like this:
^ERROR: \/var\/lib\/jenkins\/workspace\/\w+\/\w+@script\/Jenkinsfile not found$
Here we are simply using \w+\/\w+
, which means: Match any alphabetical character one or multiple times, followed by a slash followed by any word character one or multiple times