File inc/demo.inc.php added (mode: 100644) (index 0000000..419cb45) |
|
1 |
|
<?php |
|
2 |
|
// This is the files that controls the tutorials |
|
3 |
|
|
|
4 |
|
/* |
|
5 |
|
* Tutorials dispatched |
|
6 |
|
*/ |
|
7 |
|
function rg_demo($rg, $paras) |
|
8 |
|
{ |
|
9 |
|
global $rg_demos; |
|
10 |
|
|
|
11 |
|
//rg_log_ml('demo: paras: ' . print_r($paras, TRUE)); |
|
12 |
|
|
|
13 |
|
if (empty($paras)) |
|
14 |
|
return rg_template('doc/demo/list.html', $rg, TRUE /*xss*/); |
|
15 |
|
|
|
16 |
|
$demo = array_shift($paras); |
|
17 |
|
|
|
18 |
|
if (!isset($rg_demos[$demo])) |
|
19 |
|
return rg_template('doc/demo/invalid.html', $rg, TRUE /*xss*/); |
|
20 |
|
|
|
21 |
|
$d = $rg_demos[$demo]; |
|
22 |
|
|
|
23 |
|
$rg['demo']['demo'] = $demo; |
|
24 |
|
$rg['demo']['HTML:demo_name'] = rg_template('doc/demo/demos/' . $demo |
|
25 |
|
. '/name.html', $rg, TRUE /*xss*/); |
|
26 |
|
|
|
27 |
|
if (empty($paras)) { |
|
28 |
|
$page = '0'; |
|
29 |
|
} else { |
|
30 |
|
$page = array_shift($paras); |
|
31 |
|
$page = rg_force_alphanum($page); |
|
32 |
|
} |
|
33 |
|
|
|
34 |
|
$pi = FALSE; |
|
35 |
|
foreach ($d as $i => $_pi) { |
|
36 |
|
if (strcmp($page, $_pi['page']) == 0) { |
|
37 |
|
$pi = $_pi; |
|
38 |
|
break; |
|
39 |
|
} |
|
40 |
|
} |
|
41 |
|
if ($pi === FALSE) |
|
42 |
|
return rg_template('doc/demo/invalid_page.html', |
|
43 |
|
$rg, TRUE /*xss*/); |
|
44 |
|
|
|
45 |
|
rg_log_ml('DEBUG: pi: ' . print_r($pi, TRUE)); |
|
46 |
|
foreach ($pi as $k => $v) |
|
47 |
|
$rg['demo'][$k] = $v; |
|
48 |
|
|
|
49 |
|
// toc |
|
50 |
|
$c = array(); |
|
51 |
|
foreach ($d as $i => $_pi) { |
|
52 |
|
if (strcmp($page, $_pi['page']) == 0) |
|
53 |
|
$_pi['class'] = 'demo_toc_sel'; |
|
54 |
|
else |
|
55 |
|
$_pi['class'] = 'demo_toc_notsel'; |
|
56 |
|
|
|
57 |
|
$_pi['HTML:page_name'] = rg_template('doc/demo/demos/' |
|
58 |
|
. $demo . '/' . $_pi['page'] . '/name.html', |
|
59 |
|
$rg, TRUE /*xss*/); |
|
60 |
|
$c[] = $_pi; |
|
61 |
|
} |
|
62 |
|
$rg['demo']['HTML:toc'] = rg_template_table('doc/demo/toc', $c, $rg); |
|
63 |
|
|
|
64 |
|
$rg['demo']['HTML:page_name'] = rg_template('doc/demo/demos/' |
|
65 |
|
. $demo . '/' . $page . '/name.html', $rg, TRUE /*xss*/); |
|
66 |
|
|
|
67 |
|
$rg['demo']['HTML:content'] = rg_template( |
|
68 |
|
'doc/demo/demos/' . $demo . '/' . $page . '/main.html', |
|
69 |
|
$rg, TRUE /*xss*/); |
|
70 |
|
|
|
71 |
|
return rg_template('doc/demo/container.html', $rg, TRUE /*xss*/); |
|
72 |
|
} |
|
73 |
|
|
|
74 |
|
$rg_demos = array( |
|
75 |
|
'ci-1' => array( |
|
76 |
|
array( |
|
77 |
|
'page' => '0', |
|
78 |
|
'prev' => '', |
|
79 |
|
'next' => 'about' |
|
80 |
|
), |
|
81 |
|
array( |
|
82 |
|
'page' => 'about', |
|
83 |
|
'prev' => '0', |
|
84 |
|
'next' => 'add_hook' |
|
85 |
|
), |
|
86 |
|
array( |
|
87 |
|
'page' => 'add_hook', |
|
88 |
|
'prev' => 'about', |
|
89 |
|
'next' => 'trigger' |
|
90 |
|
), |
|
91 |
|
array( |
|
92 |
|
'page' => 'trigger', |
|
93 |
|
'prev' => 'add_hook', |
|
94 |
|
'next' => '' |
|
95 |
|
) |
|
96 |
|
) |
|
97 |
|
); |
|
98 |
|
|
|
99 |
|
?> |
File root/themes/default/doc/demo/demos/ci-1/about/main.html added (mode: 100644) (index 0000000..676139f) |
|
1 |
|
<div class="demo_page_title">@@demo::page_name@@</div> |
|
2 |
|
|
|
3 |
|
Below we will show you an example on how to setup RocketGit to build, test |
|
4 |
|
and deploy your application. We will use a simple 'bash' application and |
|
5 |
|
also a simple deploy script using 'rsync' to deploy it to some servers |
|
6 |
|
when you push a branch of your repository and your tests pass.<br/ > |
|
7 |
|
<br /> |
|
8 |
|
|
|
9 |
|
First, you will have to create an account and then a repository and |
|
10 |
|
setup your local environment for Git and SSH. Also, we assume that you |
|
11 |
|
already cloned the repository locally. |
|
12 |
|
These steps are not covered by this tutorial.<br /> |
|
13 |
|
<br /> |
|
14 |
|
|
|
15 |
|
Now, we assume you are in the just cloned repository local folder. |
|
16 |
|
We can start with a simple application, stored in file 'main.sh': |
|
17 |
|
<div class="term"> |
|
18 |
|
#!/bin/bash |
|
19 |
|
|
|
20 |
|
case "${1}" in |
|
21 |
|
a) echo "A" ;; |
|
22 |
|
b) echo "B" ;; |
|
23 |
|
c) echo "C" ;; |
|
24 |
|
*) echo "BAD" ;; |
|
25 |
|
esac |
|
26 |
|
|
|
27 |
|
</div> |
|
28 |
|
|
|
29 |
|
As you can see, it is a simple script. Now, we will add another script, |
|
30 |
|
'test.sh', that will test our main script: |
|
31 |
|
<div class="term"> |
|
32 |
|
#!/bin/bash |
|
33 |
|
|
|
34 |
|
if [ "`./main.sh xx`" != "BAD" ]; then |
|
35 |
|
echo "Test 'xx' failed!" |
|
36 |
|
exit 1 |
|
37 |
|
fi |
|
38 |
|
|
|
39 |
|
if [ "`./main.sh b`" != "B" ]; then |
|
40 |
|
echo "Test 'b' failed!" |
|
41 |
|
exit 1 |
|
42 |
|
fi |
|
43 |
|
|
|
44 |
|
echo "Tests passed!" |
|
45 |
|
|
|
46 |
|
</div> |
|
47 |
|
|
|
48 |
|
Next, we will add the deploy script, 'deploy.sh': |
|
49 |
|
<div class="term"> |
|
50 |
|
#!/bin/bash |
|
51 |
|
|
|
52 |
|
for s in server1 server2 server3; do |
|
53 |
|
rsync -a main.sh ${s}:/usr/local/bin/ |
|
54 |
|
done |
|
55 |
|
|
|
56 |
|
</div> |
|
57 |
|
|
|
58 |
|
'deploy.sh' will propagate our main.sh file to multiple servers. |
File root/themes/default/doc/demo/demos/ci-1/add_hook/main.html added (mode: 100644) (index 0000000..8ca6828) |
|
1 |
|
<div class="demo_page_title">@@demo::page_name@@</div> |
|
2 |
|
|
|
3 |
|
Next step is to add a webhook that will trigger our test and deploy |
|
4 |
|
phases when a push is taking place.<br /> |
|
5 |
|
<br /> |
|
6 |
|
To add this hook, you have to go login and then to to |
|
7 |
|
<b>Settings / Webhooks / Add</b> menu.<br /> |
|
8 |
|
Than, choose 'build' as the hook type by clinking 'Generic' link.<br /> |
|
9 |
|
Now, you can choose what repository and branch we want to add this hook to. |
|
10 |
|
Please note that both fields are regular expressions. So, with a single hook |
|
11 |
|
you can cover more/all repositories and branches.<br /> |
|
12 |
|
Just type your repository name. For branch, leave it empty, meaning that |
|
13 |
|
any branch will trigger the hook.<br /> |
|
14 |
|
Then, type a description to easy remember what the hook is for, for example: |
|
15 |
|
"This will deploy main.sh to the servers".<br /> |
|
16 |
|
Now, you have to choose what events will trigger the hook: we will use 'Push' |
|
17 |
|
event.<br /> |
|
18 |
|
Next, you will have to choose a build environments. For our example, |
|
19 |
|
we will use only one environment, 'debian-8.2-i386'. |
|
20 |
|
You will use multiple build environments when you want to be sure |
|
21 |
|
your application will work across a full range of distributions and |
|
22 |
|
architectures combinations.<br /> |
|
23 |
|
Next, you will be able to specify what packages are needed to build and |
|
24 |
|
test your software. You can type 'bash' there, because we have a set of |
|
25 |
|
bash scripts.<br /> |
|
26 |
|
Now, what is left is to specify what commands we want to execute. |
|
27 |
|
First command will be './test.sh' and we will check the checkbox |
|
28 |
|
"Abort on fail?". Why? Because if the test does not pass, we will |
|
29 |
|
not do the deploy step. |
|
30 |
|
Optionally, you can add some labels which will be added to your last commit |
|
31 |
|
in that branch.<br /> |
|
32 |
|
For the second command you will type './deploy.sh'. Now, press 'Add'. |
|
33 |
|
We are ready to use the hook.<br /> |
File root/themes/default/doc/demo/demos/ci-1/trigger/main.html added (mode: 100644) (index 0000000..26d0483) |
|
1 |
|
<div class="demo_page_title">@@demo::page_name@@</div> |
|
2 |
|
|
|
3 |
|
You are ready to trigger the hook and see if our first deploy will work.<br /> |
|
4 |
|
<br /> |
|
5 |
|
|
|
6 |
|
Locally, on your computer, we assume you are in the project folder, |
|
7 |
|
where we have the three bash scripts (main.sh, test.sh and deploy.sh). |
|
8 |
|
You will have to add, commit and push these files: |
|
9 |
|
<div class="term"> |
|
10 |
|
chmod a+x *.sh |
|
11 |
|
git add *.sh |
|
12 |
|
git commit -m "First commit" |
|
13 |
|
git push origin master |
|
14 |
|
|
|
15 |
|
</div> |
|
16 |
|
|
|
17 |
|
If the push is successfully, the hook will be triggered in background. |
|
18 |
|
You can go to <b>Settings / Webhooks</b> and you can check the "Last output" |
|
19 |
|
field to see the last output of the trigger. If the hook did not finished, |
|
20 |
|
the text "n/a" will appear.<br /> |
|
21 |
|
<br /> |
|
22 |
|
|
|
23 |
|
After some time, you will see the following text: |
|
24 |
|
<div class="term"> |
|
25 |
|
Worker: Builder 1 |
|
26 |
|
Date (UTC): 2016-07-22 04:30 |
|
27 |
|
Elapsed time: 133s |
|
28 |
|
|
|
29 |
|
Packages: |
|
30 |
|
Last metadata expiration check: 0:00:01 ago on Fri Jul 22 05:30:08 2016. |
|
31 |
|
Package bash-4.3.42-3.fc23.x86_64 is already installed, skipping. |
|
32 |
|
Dependencies resolved. |
|
33 |
|
Nothing to do. |
|
34 |
|
Complete! |
|
35 |
|
|
|
36 |
|
Command[./test.sh]: |
|
37 |
|
Tests passed! |
|
38 |
|
|
|
39 |
|
|
|
40 |
|
Command[./deploy.sh]: |
|
41 |
|
./deploy.sh: line 4: rsync: command not found |
|
42 |
|
./deploy.sh: line 4: rsync: command not found |
|
43 |
|
./deploy.sh: line 4: rsync: command not found |
|
44 |
|
|
|
45 |
|
</div> |
|
46 |
|
|
|
47 |
|
As you can see the tests passed, but you forgot to add rsync in the list of |
|
48 |
|
packages to be installed. Just go to <b>Settings / Webhook / List</b> and |
|
49 |
|
edit your hook: in "packages to install" text box, add 'rsync' next to 'bash' |
|
50 |
|
and press 'Edit' button.<br /> |
|
51 |
|
Now, we are ready to push again. Because you changed nothing in the repository, |
|
52 |
|
the push will succeed but will not trigger the hook. So, just do a fake |
|
53 |
|
change: |
|
54 |
|
<div class="term"> |
|
55 |
|
|
|
56 |
|
echo "Documentation is important" > README |
|
57 |
|
git add README |
|
58 |
|
git commit -m "Added README file" |
|
59 |
|
|
|
60 |
|
</div> |
|
61 |
|
|
|
62 |
|
Now, we will push again: |
|
63 |
|
<div class="term"> |
|
64 |
|
git push origin master |
|
65 |
|
|
|
66 |
|
</div> |
|
67 |
|
|
|
68 |
|
Now, the "Last output" row will be: |
|
69 |
|
<div class="term"> |
|
70 |
|
Worker: Builder 1 |
|
71 |
|
Date (UTC): 2016-07-22 04:41 |
|
72 |
|
Elapsed time: 141s |
|
73 |
|
|
|
74 |
|
Packages: |
|
75 |
|
Package bash-4.3.42-3.fc23.x86_64 is already installed, skipping. |
|
76 |
|
Dependencies resolved. |
|
77 |
|
Nothing to do. |
|
78 |
|
Complete! |
|
79 |
|
Last metadata expiration check: 0:00:13 ago on Fri Jul 22 05:40:55 2016. |
|
80 |
|
Dependencies resolved. |
|
81 |
|
================================================================================ |
|
82 |
|
Package Arch Version Repository Size |
|
83 |
|
================================================================================ |
|
84 |
|
Installing: |
|
85 |
|
rsync x86_64 3.1.1-8.fc23 updates 393 k |
|
86 |
|
|
|
87 |
|
Transaction Summary |
|
88 |
|
================================================================================ |
|
89 |
|
Install 1 Package |
|
90 |
|
|
|
91 |
|
Total download size: 393 k |
|
92 |
|
Installed size: 796 k |
|
93 |
|
Downloading Packages: |
|
94 |
|
-------------------------------------------------------------------------------- |
|
95 |
|
Total 190 kB/s | 393 kB 00:02 |
|
96 |
|
Running transaction check |
|
97 |
|
Transaction check succeeded. |
|
98 |
|
Running transaction test |
|
99 |
|
Transaction test succeeded. |
|
100 |
|
Running transaction |
|
101 |
|
Installing : rsync-3.1.1-8.fc23.x86_64 1/1 |
|
102 |
|
Verifying : rsync-3.1.1-8.fc23.x86_64 1/1 |
|
103 |
|
|
|
104 |
|
Installed: |
|
105 |
|
rsync.x86_64 3.1.1-8.fc23 |
|
106 |
|
|
|
107 |
|
Complete! |
|
108 |
|
|
|
109 |
|
Command[./test.sh]: |
|
110 |
|
Tests passed! |
|
111 |
|
|
|
112 |
|
Command[./deploy.sh]: |
|
113 |
|
ssh: Could not resolve hostname server1: No address associated with hostname |
|
114 |
|
rsync: connection unexpectedly closed (0 bytes received so far) [sender] |
|
115 |
|
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.1] |
|
116 |
|
ssh: Could not resolve hostname server2: No address associated with hostname |
|
117 |
|
rsync: connection unexpectedly closed (0 bytes received so far) [sender] |
|
118 |
|
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.1] |
|
119 |
|
ssh: Could not resolve hostname server3: No address associated with hostname |
|
120 |
|
rsync: connection unexpectedly closed (0 bytes received so far) [sender] |
|
121 |
|
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.1] |
|
122 |
|
|
|
123 |
|
</div> |
|
124 |
|
|
|
125 |
|
You can see that our 'deploy.sh' script was called, 'rsync' was present |
|
126 |
|
but failed because our server names are fake.<br/> |
|
127 |
|
<br /> |
|
128 |
|
|
|
129 |
|
That's it! You are now able to setup a test & deploy system to help you |
|
130 |
|
with the boring manual procedure. |
File root/themes/default/features.html changed (mode: 100644) (index 4b7c407..3c4b2d9) |
113 |
113 |
<div class="island"> |
<div class="island"> |
114 |
114 |
<div class="island_title">Web hooks</div> |
<div class="island_title">Web hooks</div> |
115 |
115 |
We provide flexible web hooks allowing you to automate your tasks. |
We provide flexible web hooks allowing you to automate your tasks. |
116 |
|
You can easily store a repository archive in |
|
117 |
|
<a href="https://aws.amazon.com/s3/" target="_blank">Amazon's S3</a>; |
|
118 |
|
or do a <a href="https://aws.amazon.com/codedeploy/" target="_blank">code deploy</a> |
|
119 |
|
in Amazon; or call a |
|
|
116 |
|
You can easily setup a |
|
117 |
|
<a href="/op/doc/demo/ci-1">build, test and deploy</a> hook, |
|
118 |
|
store a repository archive in |
|
119 |
|
<a href="https://aws.amazon.com/s3/" target="_blank">Amazon's S3</a>, |
|
120 |
|
do a <a href="https://aws.amazon.com/codedeploy/" target="_blank">code deploy</a> |
|
121 |
|
in Amazon, or call a |
120 |
122 |
<a href="https://aws.amazon.com/lambda/" target="_blank">Lambda</a> |
<a href="https://aws.amazon.com/lambda/" target="_blank">Lambda</a> |
121 |
123 |
function. |
function. |
122 |
124 |
Be notified in <a href="https://slack.com" target="_blank">Slack</a>. |
Be notified in <a href="https://slack.com" target="_blank">Slack</a>. |
|
134 |
136 |
</div> |
</div> |
135 |
137 |
</div> |
</div> |
136 |
138 |
|
|
|
139 |
|
<div class="island_row"> |
|
140 |
|
<div class="island_cell"> |
|
141 |
|
<div class="island"> |
|
142 |
|
<div class="island_title">Application programming interface (API)</div> |
|
143 |
|
We provide an API that allows you to control everything related |
|
144 |
|
yo your repositories, bugs, notes and pull requests. |
|
145 |
|
You can find the documentation <a href="/op/doc/api">here</a>. |
|
146 |
|
</div> |
|
147 |
|
</div> |
|
148 |
|
|
|
149 |
|
<div class="island_cell"> |
|
150 |
|
<div class="island"> |
|
151 |
|
<div class="island_title">Tutorials</div> |
|
152 |
|
We provide a set of tutorials to demonstrate our features. |
|
153 |
|
Check them <a href="/op/doc/demo">here</a>. |
|
154 |
|
</div> |
|
155 |
|
</div> |
|
156 |
|
|
|
157 |
|
<!-- |
|
158 |
|
<div class="island_cell"> |
|
159 |
|
<div class="island"> |
|
160 |
|
<div class="island_title">bla</div> |
|
161 |
|
bla |
|
162 |
|
</div> |
|
163 |
|
</div> |
|
164 |
|
--> |
|
165 |
|
</div> |
|
166 |
|
|
137 |
167 |
<div class="island_row"> |
<div class="island_row"> |
138 |
168 |
<div class="island_cell"> |
<div class="island_cell"> |
139 |
169 |
<div class="island"> |
<div class="island"> |