How can I reference the Jenkinsfile directory, with Pipeline?

前端 未结 6 1184
你的背包
你的背包 2021-02-03 18:50

I have a groovy file, I want to run from the Jenkinsfile.

ie. load script.groovy

However, I am not sure how I can reference this file if it is store

6条回答
  •  迷失自我
    2021-02-03 19:22

    You can just assume that all file operations in the Jenkinsfile are relative to the current workspace (which is the default workspace when using load inside a node).

    So if the target file (say deploy_esb.groovy) is inside the folder foo in your SCM, this should work without additional configuration:

    git branch: branch, url: 'ssh://git@giturl/integration_bus.git'
    load 'foo/deploy_esb.groovy'
    

    Or this if the file to load is in the same repository than the Jenkinsfile:

    checkout scm
    load 'foo/deploy_esb.groovy'
    

提交回复
热议问题