/
c3mc-ci-tag-ls
executable file
·63 lines (49 loc) · 1.53 KB
/
c3mc-ci-tag-ls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/data/Software/mydan/perl/bin/perl
use strict;
use warnings;
binmode STDIN, ':utf8';
binmode STDOUT, ':utf8';
binmode STDERR, ':utf8';
$|++;
use MYDan::Util::OptConf;
use YAML::XS;
use Encode;
use IPC::Open3;
=head1 SYNOPSIS
echo 'project yaml' | $0
=cut
local $/ = undef;
my $input = Encode::encode('utf8', <STDIN> );
my %project = %{ YAML::XS::Load( $input ) };
local $/ = "\n";
my $addr = $project{addr};
my $pipe = 'c3mc-ci-tag-ls-svn';
$pipe = 'c3mc-ci-tag-ls-git' if $addr =~ /git@/ || $addr =~ /\.git/ || $addr =~ /http:\/\/git/ || $addr =~ /https:\/\/git/;
$pipe = "c3mc-ci-tag-ls-harbor" if $addr =~ /^harbor:/;
if( $addr eq 'openc3://*' )
{
my @version = `c3mc-base-db-get -t openc3_job_fileserver name --filter "projectid='$project{groupid}' and status='available'"`;
chomp @version;
map{ printf "$project{id};%s\n", Encode::decode('utf8', $_ ); }@version;
exit;
}
if( $addr =~ /^ci:(\d+)$/ )
{
my @version = `c3mc-base-db-get -t openc3_ci_version name --filter "projectid='$1' and status='success'"`;
chomp @version;
map{ printf "$project{id};%s\n", Encode::decode('utf8', $_ ); }@version;
exit;
}
if( $addr =~ /^rsync:(\d+)$/ )
{
my @version = `ls /data/open-c3-data/pkgrsync/repo|grep ^$1@|awk -F@ '{print \$2}'`;
chomp @version;
map{ printf "$project{id};%s\n", Encode::decode('utf8', $_ ); }@version;
exit;
}
my $chld_in;
my $pid = IPC::Open3::open3( $chld_in, '>&STDOUT', '>&STDERR', $pipe);
print $chld_in $input;
$chld_in = undef;
waitpid( $pid, 0 );
exit $? >> 8;