Groovy web console

subscribe to the feed Subscribe
to this
site

Escaping

Published 1 month ago by weily
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
def result = []
result.add('./stylelib/js/types/utils/services/error-text-service.d.ts')
result.add('./components/preview/image--rounded-radius-large-(lg).html')
result.add('./components/detail/hero-action-teaser--other-content,top-aligned.html')
result.add('./components/raw/card/card.spec.ts')

def batch = ""
for(String file : result) {
    batch += "'${file.replaceAll('\\(', '\\\\(').replaceAll('\\)', '\\\\)').replaceAll('\\,', '\\\\,') }' "
    //batch += "'${file}' "
}

println "batch is: ${batch}"
// /var/lib/jenkins/workspace/@2@tmp/durable-0822807f/script.sh: line 1: syntax error near unexpected token `('
//println  "lftp -u svcJenkins, sftp:// -e 'mrm -r ${batch}; bye'"