0
votes

I have two jobs that kind of upload the file to the server. Both jobs are the same except they upload to different remote URLs. Currently, I am using two Jenkins files in the same git repository for these jobs. But these files are almost the same except server URLs are different. I tried to use the single Jenkins file and passing the server URL as a parameter from a new parent job. These two children's jobs are running concurrently and one of them is succeeding while another one is failing.

So, My question is can we run multiple jobs pointing to the single Jenkinsfile?

1
Yes, your approach was correct and does absolutely work. I'd recommend to set the default vaules of the parameters according to the respective URL. Without the concrete error message it is impossible to tell why the job failed. Maybe a shared resource? Please edit your question and add the error of the failing pipeline.smelm
@smelm How does Jenkins uses Jenkins file?user2719152
Parameters' default values have been set in Jenkins. And these values are passed to the jobs correctly. But in one job, some part of the job is missed and it's going to the next stage which uses artefact built in the previous stage. Since the previous stage didn't run fully, so there is no artifact stashed, and in the next stage when it tries to unstash, that job fails. While another job is running perfectly fine as expected.user2719152

1 Answers

0
votes

My approach works fine but I was making silly mistakes of not passing the workspace name as a parameter and thus both child jobs were sharing a workspace. After setting the workspace name through a parameter, this approach works fine.