Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/ci_scripts/notify_discord.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10853 - (show annotations) (download) (as text)
Wed Aug 16 15:07:58 2023 UTC (7 months, 3 weeks ago) by zmatsuo
File MIME type: text/x-perl
File size: 2211 byte(s)
buildtools/cygwin64 に discord通知に使用するパッケージもインストール

- buildtools/install_cygwin.cmake
  - discoard通知に使用するパッケージもインストールするようにした
- buildtools/find_cygwin.bat
  - ビルドで使用するcygwinを探す
  - find_cygwin.bat を使用するようにした
    - installer/release.bat
    - ci_scripts/notify.bat
- ci_scripts/notify_discord.pl
  - 改行コードを LF に変更した
1 #!/usr/bin/perl
2
3 use strict;
4 use utf8;
5 use JSON;
6 use LWP::UserAgent;
7 use LWP;
8
9 if (not defined $ENV{APPVEYOR_PROJECT_SLUG}) {
10 # test
11 $ENV{APPVEYOR_BUILD_WORKER_IMAGE} = "Image Name";
12 $ENV{APPVEYOR_PROJECT_SLUG} = "teraterm";
13 $ENV{APPVEYOR_REPO_NAME} = "APPVEYOR_REPO_NAME";
14 $ENV{APPVEYOR_REPO_BRANCH} = "APPVEYOR_REPO_BRANCH";
15 $ENV{APPVEYOR_REPO_COMMIT} = "APPVEYOR_REPO_COMMIT";
16 $ENV{APPVEYOR_REPO_COMMIT} = "31";
17 #$ENV{WEBHOOK_URL} = "https://discord.com/api/....";
18 }
19
20 #print "ENV{APPVEYOR}=$ENV{APPVEYOR}\n";
21 #print "ENV{WEBHOOK_URL}=$ENV{WEBHOOK_URL}\n";
22
23 if (not defined $ENV{APPVEYOR}) {
24 print "Do not run on Appveyor\n";
25 exit 0;
26 }
27 if (not defined $ENV{WEBHOOK_URL}) {
28 print "\$WEBHOOK_URL is empty\n";
29 exit 0;
30 }
31
32 my $hook = $ENV{WEBHOOK_URL};
33 my $result = $ARGV[0];
34 my $color;
35 if ($result =~ /success/) {
36 $color = "255"; # 0x0000ff green
37 } else {
38 $color = "16711680"; # 0xff0000 red
39 }
40 my $image = $ENV{APPVEYOR_BUILD_WORKER_IMAGE};
41
42 my $revision = "$ENV{APPVEYOR_REPO_COMMIT}";
43 my $rev_url = "https://osdn.net/projects/ttssh2/scm/svn/commits/$revision";
44 my $artifacts_url = "https://ci.appveyor.com/project/$ENV{APPVEYOR_ACCOUNT_NAME}/$ENV{APPVEYOR_PROJECT_SLUG}/build/job/$ENV{APPVEYOR_JOB_ID}/artifacts";
45
46 my $description = <<"EOS";
47 $ENV{COMPILER_FRIENDLY}/$ENV{COMPILER}
48 Commit \[r$revision\]($rev_url) by $ENV{APPVEYOR_REPO_COMMIT_AUTHOR} on $ENV{APPVEYOR_REPO_COMMIT_TIMESTAMP}
49 \[Download\]($artifacts_url)
50 EOS
51
52 my %json= (
53 "content" => "build $result r$revision",
54 "embeds" => [{
55 # "title" => "",
56 "color" => $color,
57 "description" => "$description",
58 }]
59 );
60
61 #print encode_json(\%json);
62
63 if(1) {
64 # LWP
65 my $browser = LWP::UserAgent->new;
66
67 my $client = HTTP::Request->new(POST => $hook);
68 $client->content_type('application/json');
69 $client->header("User-Agent" => "DiscordBot");
70
71 $client->content(encode_json(\%json));
72
73 my $response = $browser->request($client);
74 if ($response->is_success) {
75 print $response->content;
76 }
77 else {
78 print $response->status_line, "\n";
79 }
80
81 } else {
82 # curl
83 my $curl = 'curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d';
84 my $cmd=$curl . " '" . encode_json(\%json) . "' '" . $hook . "'";
85 system($cmd);
86 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26