I am trying to implement continuous deployment using Jenkins and that involves sending a jar file to a remote server and start the jar once its on the remote server.
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 file
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
[email protected]:/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"
It looks like your deploy.sh
isn't executable, as you can see with the error code 126 “command not executable".
ls -l path/to/
the output should be similar to:
-rw-r--r-- 1 user staff 402 Aug 1 10:55 deploy.sh
If your file hasn't the executable flag, you should change the access right with chmod
, something like:
chmod +x path/to/deploy.sh
the result should be then something like (notice the 4th char x):
-rwxr--r-- 1 user staff 402 Aug 1 10:55 deploy.sh
If your script is committed to git, you can also do:
git update-index --chmod=+x path/to/deploy.sh
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With