How to load a dynamic Jenkins file during build

I am trying to create a Jenkins pipeline project that uses different Jenkinsbuild files depending on the job parameter. Is there a way to load the Jenkins build file during job execution, for example:

node {
   stage("Determine build parameter") {
      String jenkinsFile = .....
   }
   // here the Jenkins build file should be loaded
   loadSomeHowBuildFile jenkinsFile

   // ... and then the pipeline steps defined in the jenkinsFile are executed 
}

It would be great that this would work ...

+4
source share
1 answer

I found a solution that is pretty simple. Jenkins needs to upload a file

node {
   stage("Determine build file") {
      String jenkinsFile = /path/to/Jenkins/build/file
   }
   // here the Jenkins build file is loaded and executed
   load jenkinsFile
}
+1
source

Source: https://habr.com/ru/post/1683809/


All Articles