I'm not able to build a job from jenkins pipeline passing a variable for job name. Please find below the code snippet. If I replace ${service} with 'microservice' it will trigger the job
service = 'microservice'
echo "TESSSSSSSSTTT ${service}"
build(job: "'${service}'", parameters: [string(name: 'ENVNAME', value: 'uat')])
The error faced is:
[Pipeline] echo
TESSSSSSSSTTT microservice
[Pipeline] build
[Pipeline] End of Pipeline
ERROR: No item named 'microservice' found
Finished: FAILURE
I'm using this method because I want to hit a build command for all the microservices passing the names with multi-line string parameter, finally I want to set this build into a loop.
I assume your job is not called 'microservice'
in Jenkins but microservice
(without the ticks).
So change your build
line to not include single quotes after the double quote:
build(job: "${service}", parameters: [string(name: 'ENVNAME', value: 'uat')])
Did some simple test with my jenkins instance and was able to call a job by setting the service variable to an existing job name.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.