gpt4 book ai didi

java - -bash : ./deploy.sh : Permission denied , 错误:脚本返回退出代码 126

转载 作者:行者123 更新时间:2023-11-29 08:25:23 25 4
gpt4 key购买 nike

我正在尝试使用 Jenkins 实现持续部署,这涉及将 jar 文件发送到远程服务器并在其位于远程服务器上后启动 jar。

The problem is that i keep getting access denied error and i have tried every account i have on my remote and local server nothing seems to work. I get the same Error.

Jenkins 文件

pipeline {
agent any

stages {

stage ('Packaging stage') {

steps {
withMaven(maven : 'Maven') {
sh 'mvn clean install'
}
}
}

stage ('Deploy To Dev Server') {

steps {
sh './deploy.sh'
}
}
}

}

deploy.sh

#!/usr/bin/expect -f
spawn scp -P 10022 /var/lib/jenkins/.m2/repository/org/hector/eureka-naming-server/0.0.1-SNAPSHOT/eureka-naming-server-0.0.1-SNAPSHOT.jar
myUserName@myRemoteServer.net:/home/myname/repository/eureka-service-deploy

expect "password: "

send "myPassword\r"

expect "$ "
send "other_command_to_execute_on_remote\r"
expect "$ "
send "exit\r"
echo "Successfully sent file"

enter image description here

最佳答案

看起来您的 deploy.sh 不可执行,您可以看到错误代码 126“command not executable”。

ls -l path/to/

输出应该类似于:

-rw-r--r--    1 user  staff      402 Aug  1 10:55 deploy.sh

如果您的文件没有可执行标志,您应该使用 chmod 更改访问权限,例如:

chmod +x path/to/deploy.sh

结果应该类似于(注意第 4 个字符 x):

-rwxr--r--    1 user  staff      402 Aug  1 10:55 deploy.sh

如果您的脚本提交给 git,您还可以:

git update-index --chmod=+x path/to/deploy.sh

关于java - -bash : ./deploy.sh : Permission denied , 错误:脚本返回退出代码 126,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53692805/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com