Triggering the hook
You are ready to trigger the hook and see if our first deploy will work.
Locally, on your computer, we assume you are in the project folder,
where we have the three bash scripts (main.sh, test.sh and deploy.sh).
You will have to add, commit and push these files:
chmod a+x *.sh
git add *.sh
git commit -m "First commit"
git push origin main
If the push was done successfully, the hook will be triggered in background.
You can go to
Settings / Webhooks and you can check the "Last output"
field to see the last output of the trigger. If the hook did not finished,
the text "n/a" will appear.
After some time, you will see the following text:
Worker: Builder 1
Date (UTC): 2016-07-22 04:30
Elapsed time: 133s
Packages:
Last metadata expiration check: 0:00:01 ago on Fri Jul 22 05:30:08 2016.
Package bash-4.3.42-3.fc23.x86_64 is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!
Command[./test.sh]:
Tests passed!
Command[./deploy.sh]:
./deploy.sh: line 4: rsync: command not found
./deploy.sh: line 4: rsync: command not found
./deploy.sh: line 4: rsync: command not found
As you can see the tests passed, but we forgot to add
rsync to the list of
packages to be installed. Just go to
Settings / Webhook / List and
edit your hook: in "Packages to install" text box, add 'rsync' next to 'bash'
and press 'Edit' button.
Now, we are ready to push again. Because we changed nothing in the repository,
the push will succeed but will not trigger the hook. So, just do a fake
change:
echo "Documentation is important" > README
git add README
git commit -m "Added README file"
Now, we will push again:
git push origin main
Now, the "Last output" row will be:
Worker: Builder 1
Date (UTC): 2016-07-22 04:41
Elapsed time: 141s
Packages:
Package bash-4.3.42-3.fc23.x86_64 is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!
Last metadata expiration check: 0:00:13 ago on Fri Jul 22 05:40:55 2016.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
rsync x86_64 3.1.1-8.fc23 updates 393 k
Transaction Summary
================================================================================
Install 1 Package
Total download size: 393 k
Installed size: 796 k
Downloading Packages:
--------------------------------------------------------------------------------
Total 190 kB/s | 393 kB 00:02
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Installing : rsync-3.1.1-8.fc23.x86_64 1/1
Verifying : rsync-3.1.1-8.fc23.x86_64 1/1
Installed:
rsync.x86_64 3.1.1-8.fc23
Complete!
Command[./test.sh]:
Tests passed!
Command[./deploy.sh]:
ssh: Could not resolve hostname server1: No address associated with hostname
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.1]
ssh: Could not resolve hostname server2: No address associated with hostname
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.1]
ssh: Could not resolve hostname server3: No address associated with hostname
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.1]
You can see that our 'deploy.sh' script was called, 'rsync' was present
but failed because our server names are fake.
That's it! You are now able to setup a test & deploy system to help you
with the boring manual procedures.
Next sections will show you some practical examples.