I have this bash script that lists all the jobs on jenkins. I have jobs with spaces within them and some without.
#!/bin/bash
for job in $(java -jar jenkins-cli.jar -s $JENKINS_URL -auth admin:admin list-jobs)
do
file_name="$(echo "$job" | sed 's/ /-/g').xml"
echo $file_name
java -jar jenkins-cli.jar -s $JENKINS_URL get-job $job > $file_name
done
I have jobs called for example:
- new job
- test-job
When I run this script however I get the following result:
new.xml
job.xml
test-job.xml
Instead I would like to output:
new-job.xml
test-job.xml
What am I missing here?