Use Jenkisfile located in the same repo as the seed-job DSL groovy file

Viewed 212

My current folder structure looks like this

.
├── README.md
└── jobs
    ├── cloneImages.groovy
    ├── pipelineJobs
       └── cloneImageJob.Jenkinsfile

All the of the above is in one github repo. cloneImages.groovy is a jenkins seed-job using Process Job DSLs.

Basically I want to create a pipeline job using this. And the Jenkinsfile I want to load for cloneImageJob is in the same repo.

Once thing I can do it to checkout the repo again and navigate to the Jenkinsfile but that is not a clean solution imho. Using a scm script is also not an option since the code starts looking really dirty(lots of bash and concatinations).

So is there a way where I can get the Jenkinsfile for a job that Im creating using job DSL from the same repo ?

cloneImages.groovy:

pipelineJob("clone-images") {
    description('''
''')
    parameters {
        choiceParam // some parameters
    }
    definition {
            // Need a mechanism here that can pull the Jenkinsfile thats in the same repo as cloneImages.groovy located one folder down i.e. pipelineJobs/
        }
}
0 Answers
Related