VSS-打标签自动发邮件的功能

VSS-打标签自动发邮件的功能

 

在项目组中有1个组采用VSS进行执行码版本管理,但是开发人员何时提交新版本都需要打电话通知,感觉这个过程比较繁琐,就希望开发人员提交新版本时能够自动给相应的人发邮件!下面是相关的执行码,前提是开发人员提交新版本时必须打标签;另外在建立1个新的项目时,需要在这个项目文件下存放1个txt文件,名字为项目名称名,内容存储需要发邮件的对象就OK了。

 

#!/usr/bin/perl

use Net::SMTP;

 

########################
###########发邮件子函数
sub SendMailSoftApp{
my ($smtp_server,$from,$to,$title,$msg) = @_;
   
  my  $smtp = Net::SMTP->new($smtp_server)||
       die 'Cannot connect to server /'$smtp_server/'';
     $smtp->auth('liujunmei','123456');
     $smtp->mail($from);
     $smtp->to($to);
     $smtp->data();
     $smtp->datasend('From: '.$from);
     $smtp->datasend("/n");
     $smtp->datasend('To: '.$to);
     $smtp->datasend("/n");
     $smtp->datasend('Subject: '.$title);
     $smtp->datasend("/n/n");
     $smtp->datasend("$msg/n");
     $smtp->dataend();
     $smtp->quit;
}

##############################333

###变量定义区
my ($lable,$programe,$time);
$path="d:/vss/data/labels/";
$now=time-24*60*60*3;

my $myfile;
my $timer;
my $smtp_server="172.16.254.2";
my $from="bugzilla-项目申请";
my $title;
##############
##流程控制
@file=glob("*");
foreach $file (@file)
{
 $myfile=$path.$file;
 $mtime=(stat($file))[9];
 ##获得上次修改的时间
 if ($mtime > $now)
 {
  open(FH,$myfile)||die "unable to append to $myfile: $!";
  @_=<FH>;
  foreach $content(@_)
  {
                       
   if($content=~/^Label/)
   {
   $label=$content;
                        }
   if($label=~/pass/||$label=~/run/)
                        {
   last;
   }
#######################################
my $msg=<<HTML;

$label

HTML
#########################################
   
   if($content=~/[[]/$//(.*)/)
   {
          $programe=$content;
   $subprograme=substr($programe,3);
   chop $subprograme;
   chop $subprograme;
                         
          ($programe1,$programe2)=split(, $subprograme,2);
    
   
    
   }
                        if($content=~/^Time/)
   {
   $timer=substr($content,7);
                   #     print $content;
   #print $now;
   #print "/n";
                       # print $timer;
   if($timer>$now)
    {
#     print $programe1;
     $title="[VSS]提交新版本---".$programe1."(内容为空)";
                          my $Tpropath="d:/vss/data/progra/";
     my $propath=$Tpropath.$programe1.".txt";
    # print $propath;
     open(FILE,$propath)||die "connot to append to $propath: $!";
     @mail=<FILE>;
     foreach $mail(@mail)

      {     
        chomp $mail;
       SendMailSoftApp($smtp_server,$from,$mail,$title,$msg) ;
      }
                                         close(FILE);
    }
   }
          
   
  

  }
 close(FH);

 }

 

 


}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值