我正在尝试使用 Jenkins 实现持续部署,这涉及到将 jar 文件发送到远程服务器,并在远程服务器上启动该 jar 文件。
问题是我不断收到访问被拒绝错误,并且我已经尝试了远程和本地服务器上的每个帐户似乎都不起作用。我犯了同样的错误。
詹金斯文件
pipeline {
agent any
stages {
stage ('Packaging stage') {
steps {
withMaven(maven : 'Maven') {
sh 'mvn clean install'
}
}
}
stage ('Deploy To Dev Server') {
steps {
sh './deploy.sh'
}
}
}
}
部署.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
[email protected] /cdn-cgi/l/email-protection:/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"
看起来像你的deploy.sh
不可执行,如错误代码 126 所示“命令不可执行".
ls -l path/to/
输出应类似于:
-rw-r--r-- 1 user staff 402 Aug 1 10:55 deploy.sh
如果您的文件没有可执行标志,您应该使用以下命令更改访问权限chmod
, 就像是:
chmod +x path/to/deploy.sh
结果应该是这样的(注意第四个字符x):
-rwxr--r-- 1 user staff 402 Aug 1 10:55 deploy.sh
如果您的脚本已提交到 git,您还可以执行以下操作:
git update-index --chmod=+x path/to/deploy.sh
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)