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

前端 未结 6 1333
面向向阳花
面向向阳花 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:12

    I was able to get my script execution working with a simplified derivative of Rafael Manzoni's response. I wondered about the whole "JOB_NAME@script" thing and found that unnecessary, at least for declarative using our version of Jenkins. Simply set the access permissions on the workspace. No need to go any deeper than that.

    stage('My Stage') {
        steps {
            sh "chmod +x -R ${env.WORKSPACE}"
            sh "./my-script.sh"
        }
    }
    

提交回复
热议问题