script.sh: line 1: ./gradlew: No such file or directory on Jenkins

妖精的绣舞 提交于 2020-02-15 06:46:37

问题


This is error message I got

./gradlew clean assembleRelease /Users/bhanukaisuru/.jenkins/workspace/OrelGo@tmp/durable-b74adbad/script.sh: line 1: ./gradlew: No such file or directoryPipeline Script

Pipeline Script

stage('Build Release APK') {
             sh "./gradlew clean assembleRelease"
         }

回答1:


You do not need to specify the Jenkins workspace with the commands sh and bat if you want to execute a command on the root level of it.

sh 'mkdir test' would create a folder in <jenkins_workspace>/test for example.

If gradlew is located on the root of the Jenkins workspace the following should be sufficent:

sh "gradlew clean assembleRelease"

otherwise a full path works as well.




回答2:


You should CD to where your gradlew binary folder is, or using full path of the gradlew. because the command you run is executed in epemeral directory, not in the jenkins home. you can use ${JENKINS_HOME} to use the path of your jenkins home



来源:https://stackoverflow.com/questions/60129590/script-sh-line-1-gradlew-no-such-file-or-directory-on-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!