声明:本博客只代表作者本人,不代表作者所在公司和组织等。如因此采用本博客内容造成的损失和不便,本博客概不负责。如需相应service请联系对应厂商
1,下载client
2,编写脚本
脚本A(foreverToken.pl)
-----------------
#!/usr/bin/perl -w
use BuildForge::Services;
$conn = new BuildForge::Services::Connection('localhost');
$token = $conn->authUser('yq','qq');
print "token: $token \n";
#$conn->authToken($token);
# Getting existing projects
$project = BuildForge::Services::DBO::Project->findByName($conn, 'proj1');
# Getter / setter functions
$id = $project->getProjectId();
$name = $project->getName();
$class = $project->getBuildClass();
$env = $project->getEnvironmentId();
print "Name: $name \n";
print "ID: $id \n";
print "Class: $class \n";
print "Env ID: $env \n";
#wait for a very long, the other script can use the same session.
my $verbose = 99999999;
my $idx = 0;
while ($idx<$verbose) {
sleep 20;
$idx =$idx+1;
warn "index: $idx\n";
}
$conn->logout;
$conn->close;
脚本B(shareToken.pl)
-------------------------
#!/usr/bin/perl -w
use BuildForge::Services;
$conn = new BuildForge::Services::Connection('localhost');
#$token = $conn->authUser('yq','qq');
#get the token after the scriptA is executed
$conn->authToken('77baef380c571000ca2b83f44d314d31');
# Getting existing projects
$project = BuildForge::Services::DBO::Project->findByName($conn, 'proj2share');
# Getter / setter functions
$id = $project->getProjectId();
$name = $project->getName();
$class = $project->getBuildClass();
$env = $project->getEnvironmentId();
print "Name: $name \n";
print "ID: $id \n";
print "Class: $class \n";
print "Env ID: $env \n";
#don't logout or close, for myabe other scripts are using this session at the same time
print "exit";
3, 执行脚本
如图1所示的目录结构
perl -I "c:\\autofvt\rbf-services\lib" foreverToken.pl
得到输出token,后修改shareToken.pl,然后在新的cmd窗口执行shareToken.pl
perl -I "c:\\autofvt\rbf-services\lib" shareToken.pl