Created
November 8, 2021 02:41
-
-
Save s1037989/f72d0fa8029b08c39933b070e53436f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Mojolicious::Lite -signatures; | |
# for i in $(carton exec -- perl jenkins.pl jenkins http://localhost:3000/); do k=$(mojo get $i); for j in $(mojo get $i/ws); do echo -e "$j\t$k"; done; done | |
use Mojo::Util qw(md5_sum); | |
get '/' => sub ($c) { | |
$c->render(json => { | |
number => 1, | |
url => $c->url_for('job1', name1 => 'a')->to_abs, | |
jobs => [ | |
{ | |
number => 2, | |
url => $c->url_for('job2', name1 => 'b', name2 => 'bb')->to_abs, | |
jobs => [ | |
{number => 3, url => $c->url_for('job3', name1 => 'c', name2 => 'cc', name3 => 'ccc')->to_abs}, | |
{number => 4, url => $c->url_for('job3', name1 => 'd', name2 => 'dd', name3 => 'ddd')->to_abs}, | |
{number => 5, url => $c->url_for('job3', name1 => 'd', name2 => 'dd', name3 => 'ddd')->to_abs}, | |
] | |
}, | |
{ | |
number => 6, | |
url => $c->url_for('job2', name1 => 'e', name2 => 'ee')->to_abs, | |
jobs => [ | |
{number => 7, url => $c->url_for('job3', name1 => 'f', name2 => 'ff', name3 => 'fff')->to_abs}, | |
{number => 8, url => $c->url_for('job3', name1 => 'g', name2 => 'gg', name3 => 'ggg')->to_abs}, | |
{number => 9, url => $c->url_for('job3', name1 => 'h', name2 => 'hh', name3 => 'hhh')->to_abs}, | |
] | |
} | |
] | |
}); | |
}; | |
my @hosts = map { substr(md5_sum($_), 0, 5) } 0..int(rand(5)); | |
get '/job/:name1/:ws' => {ws => ''} => sub ($c) { | |
if ($c->param('ws')) { | |
$c->render(text => join "\n", @hosts[0..int(rand($#hosts))]); | |
} | |
else { | |
$c->render(text => sprintf "%s\t%s", scalar localtime, int(rand(3))); | |
} | |
} => 'job1'; | |
get '/job/:name1/job/:name2/:ws' => {ws => ''} => sub ($c) { | |
if ($c->param('ws')) { | |
$c->render(text => join "\n", @hosts[0..int(rand($#hosts))]); | |
} | |
else { | |
$c->render(text => sprintf "%s\t%s", scalar localtime, int(rand(3))); | |
} | |
} => 'job2'; | |
get '/job/:name1/job/:name2/job/:name3/:ws' => {ws => ''} => sub ($c) { | |
if ($c->param('ws')) { | |
$c->render(text => join "\n", @hosts[0..int(rand($#hosts))]); | |
} | |
else { | |
$c->render(text => sprintf "%s\t%s", scalar localtime, int(rand(3))); | |
} | |
} => 'job3'; | |
app->start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment