Pick JenkinsFile from custom location in pipeline plugin of jenkins

女生的网名这么多〃 提交于 2019-12-10 16:44:52

问题


Can jenkins pipeline plugin pick jenkinsfile from a custom location and start the build?

i don't want to keep jenkinsfile inside the source code. If there is any change in the source code. jenkinsfile from custom location should be picked and build should be started.

Example:/home/test/jenkinsfile


回答1:


You can of-course just try to put a custom location (I wouldn't see why it can't) as long as the user has rights to read the location.

If it is a multibranch pipeline, than no. Because indexing is based the presence of a Jenkinsfile (only branches that contain a Jenkinsfile are indexed)

The thought behind having the logic of your build inside your repository is, that this is source controlled together with your sources. When you change something in your sources and this affects your build, than building that specific commit will have all the logic. If you move this outside your repository your build logic and your repository are very likely to get out of sync.

EDIT You can workaround this by adding a Jenkinsfile that will load the other file

Jenkinsfile:

load "/home/test/Jenkinsfile"

However as far as I know, directoriees are relative to the workspace. So if you have any dir("path/to/other/dir"){..} than that will run relative to the workspace of the job, which makes your static Jenkinsfile very confusing to read.



来源:https://stackoverflow.com/questions/40280872/pick-jenkinsfile-from-custom-location-in-pipeline-plugin-of-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!