I'm using Jenkins to build and deploy HTML documentation to a local Apache web server for our devs to use. When I run the commands in the terminal, everything installs properly (Proving the server is setup properly). However, when run the same commands from within Jenkins, they get called but nothing changes. It doesn't delete html.zip
(Line 18), doesn't move the files into /var/html/www/subdir
, and doesn't report any errors outside of the curl
request failing. I'm a bit lost as to what I'm doing wrong.
I should note that I'm calling this entire script as sudo
. I know this is insecure but I figured I would try to get the script working first, then change that later. To ensure user
doesn't run into issues installing the documentation, I've temporarily allowed it to run any command as sudo without a password. Again, I know this is insecure, but in the spirit of trying to eliminate variables, I added this.
Jenkins calls this script like so:
sudo ./documentation-publisher.sh
Permissions on the script are the least restrictive for now, 777. Calling ls -l
on the script reports:
-rwxrwxrwx 1 devop developers 1144 Dec 3 10:29 documentation-publisher.sh
I tried a suggestion from this post about explicitly setting the path in the script, but noticed no differences. An explicit path to each of the commands used doesn't change the behavior either.
#!/bin/sh -x
echo "Archiving generated HTML for transfer..."
cd Example/docs/html/
zip -r html.zip ./
scp -i ~/.ssh/id_rsa html.zip user@my.host.example.com:/home/user
ssh -i ~/.ssh/id_rsa user@my.host.example.com
echo "Extracting generated HTML into www directory..."
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
unzip -o html.zip -d ./subdir
rm -r /var/www/html/subdir
mkdir /var/www/html/subdir
cp -r ./subdir/* /var/www/html/subdir/
echo "Cleaning up after file transfer..."
rm -rf ./subdir
rm ./html.zip
echo "Testing install..."
curl -f my.host.example.com/subdir/index.html
exit
What could I be doing wrong?