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

前端 未结 6 1328
面向向阳花
面向向阳花 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-05 01:17

    I compiled all the answers above and for me it worked like this:

    stage('Run Script'){
            steps {
                    script {
                            sh('cd relativePathToFolder && chmod +x superscript.sh && ./superscript.sh parameter1 paraeter2')
                        }
                    }
    }
    

    Thanks to @Rafael Manzoni @Keith Mitchell and @Jayan

提交回复
热议问题