echo "Stop Tomcat server on ${HOST}..."ssh ${SSH_OPTS} ${SSH_USER}@${HOST} "sudo /sbin/service tomcat-${ENV} stop"ssh '-o StrictHostKeyChecking=no -i ~/.ssh/my.pem' my-...@myhost.com 'sudo /sbin/service tomcat-dev stop'
ssh -o StrictHostKeyChecking=no -i ~/.ssh/my.pem my-...@myhost.com 'ln -s ~/properties/my-dev.properties ~/properties/my.properties'
{ "command": "bash", "timeout": -1.0, "arguments": [ "-c", "./src/main/config/scripts/wrapper.sh -h ${HOSTS_INT}" ], "run_if": "passed", "type": "exec"}{ "name": "SSH_OPTS", "value": "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /path/to/.ssh/my.pem"}Hello Chris,
I figured you were using it like you showed. You're also right that all of this is behavior of bash, rather than GoCD.
Your JSON is equivalent to calling a script such as this:
#!/bin/bash
export SSH_HOSTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /path/to/.ssh/my.pem"
bash -c './src/main/config/scripts/wrapper.sh -h ${HOSTS_INT}'
You should see whatever behavior you're seeing when run through GoCD.
I would suggest using a script such as this one, to understand the effect of quotes and eval, etc.
#!/bin/bash
echo "I got: $# arguments"
for idx in `seq "$#"`; do
echo "$idx: $1"
shift
done
For instance, use it like this:
#!/bin/bash
SSH_USER="ssh-user"
HOST="ssh-host"
SSH_OPTS="-o StrictHostKeyChecking=no -i ~/.ssh/my.pem"
echo "Without quotes:"
./how-many-args.sh ${SSH_OPTS} ${SSH_USER}@${HOST} "sudo /sbin/service tomcat-${ENV} stop"
echo
echo "With quotes:"
./how-many-args.sh "${SSH_OPTS}" ${SSH_USER}@${HOST} "sudo /sbin/service tomcat-${ENV} stop"
echo
echo "With eval:"
eval ./how-many-args.sh "${SSH_OPTS}" ${SSH_USER}@${HOST} "sudo /sbin/service tomcat-${ENV} stop"
echo
echo "With eval and protection for the last arg:"
eval ./how-many-args.sh "${SSH_OPTS}" ${SSH_USER}@${HOST} '"sudo /sbin/service tomcat-${ENV} stop"'
echo
--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/5f2f25e3-6061-48a7-a1a9-5475c655cc0b%40googlegroups.com.
#!/bin/bash -x
die() { echo >&2 "$@" exit 1}
# Get HOST Name for Deploymentwhile getopts ":h:" opt; do case ${opt} in h) HOSTS=$OPTARG ;; \?) die "Invalid option: -$OPTARG" ;; :) die "Invalid option: $OPTARG requires an argument" ;; esacdoneshift $((OPTIND - 1))
if [[ -z $HOSTS ]] ; then die "BAD ARGUMENTS: Host was not supplied"fi
OIFS=$IFSIFS=";"for HOST in $HOSTS; do SSH_OPTS="-o StrictHostKeyChecking=no -i /path/to/.ssh/my.pem" ssh -v "$SSH_OPTS" my-user@$HOST "sudo sendmail m...@my-company.com < email.txt" if [ $? -ne 0 ]; then die "Stopping Tomcat failed!" fidoneIFS=$OIFSexit 0To unsubscribe from this group and stop receiving emails from it, send an email to go...@googlegroups.com.
It also feels like defining the variable in the same script is getting treated differently than passing them into another script, but that could be crazy.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/84a61c5a-1d01-4bb1-ab29-a251b1d4cd24%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/84a61c5a-1d01-4bb1-ab29-a251b1d4cd24%40googlegroups.com.