How can I reference the Jenkinsfile directory, with Pipeline?

前端 未结 6 1202
你的背包
你的背包 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:04

    if this script.groovy file is in the root of your project, like the Jenkinsfile, it will be fetched from git into the same folder as your Jenkinsfile. So the command you are using should work OK.

    Are you getting some error? Please provide more details if so.

    EDIT: now I can see what's in your Jenkinsfile, I can see you are checking out a git project called integration_bus which is where the groovy script resides. You can specify the location where that is checked out like this:

    checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'esb_deploy']], submoduleCfg: [], userRemoteConfigs: [[url: 'ssh://git@giturl/integration_bus.git']]])
    

    as opposed to what you have

    git branch: branch, url: 'ssh://git@giturl/integration_bus.git'
    

    Then you should be able to reference the groovy script in the esb_deploy folder like this

    load 'esb_deploy/esb_deploybar_pipeline/deploy_esb.groovy'
    

提交回复
热议问题