I have the following Pipeline step to find specific files:
sh("find . -regex '.*${packageName}-[0-9.]+-.\\.noarch\\.rpm'")

The Output:
[Pipeline] sh
+ find . -regex '.*package-name-[0-9.]+-.\.noarch\.rpm'
This does not return any result.

Both of these two works in Bash:
find . -regex '.*meos-dashboard-[0-9.]+-.\.x86_64\.rpm'
find . -regex .*meos-dashboard-[0-9.]+-.\.x86_64\.rpm

This groovy code work:
def find = "find . -regex .*package-name-[0-9.]+-.\\.noarch\\.rpm".execute()
println find.text

This groovy code does not work:
def find = "find . -regex '.*package-name-[0-9.]+-.\\.noarch\\.rpm'".execute
()
println find.text


So it seems Groovy does not work with surrounding the regex with single 
quote. Trying without does not go so well either:
sh("find . -regex .*${packageName}-[0-9.]+-.\\.noarch\\.rpm")

The output:
[Pipeline] sh
+ find . -regex '.*package-name-[0-9.]+-..noarch.rpm'
Pipeline seems to remove the "\" from the regular expression when I am not 
using the single quote.


Any idea what is the problem here? Pipeline or Groovy?

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/a8a22c0b-d707-4fdc-b41c-91e8b12d756a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to