Ere*_*ent 2 java bash jenkins spring-boot
我正在尝试使用 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'
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
部署文件
#!/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"
Run Code Online (Sandbox Code Playgroud)
看起来您deploy.sh的不可执行,正如您所看到的错误代码 126“命令不可执行”。
ls -l path/to/
Run Code Online (Sandbox Code Playgroud)
输出应类似于:
-rw-r--r-- 1 user staff 402 Aug 1 10:55 deploy.sh
Run Code Online (Sandbox Code Playgroud)
如果您的文件没有可执行标志,您应该使用 更改访问权限chmod,例如:
chmod +x path/to/deploy.sh
Run Code Online (Sandbox Code Playgroud)
结果应该是这样的(注意第 4 个字符x):
-rwxr--r-- 1 user staff 402 Aug 1 10:55 deploy.sh
Run Code Online (Sandbox Code Playgroud)
如果您的脚本提交给 git,您还可以执行以下操作:
git update-index --chmod=+x path/to/deploy.sh
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6533 次 |
| 最近记录: |