How do I make Jenkins 2.0 execute a sh command in the same directory as the checkout?

前端 未结 6 1339
面向向阳花
面向向阳花 2021-02-05 00:45

Here\'s my Jenkins 2.x pipeline:

node (\'master\'){
    stage \'Checkout\'
    checkout scm
    stage \"Build Pex\"
    sh(\'build.sh\')
}

When

6条回答
  •  长发绾君心
    2021-02-05 01:19

    You can enclose your actions in dir block.

    checkout scm
    stage "Build Pex"
    dir ('') { 
        sh('./build.sh')
    }
    ... or ..
    checkout scm
    stage "Build Pex"
    sh(""" /build.sh""")
    
    ...
    

    is place holder your actual directory. By default it is a relative path to workspace. You can define absolute path, if you are sure this is present on the agent.

提交回复
热议问题