使用詹金斯码头图像

时间:2017-05-15 15:17:48

标签: docker jenkins

我正在准备基于jenkins的码头图片:lts。要设置初始配置,我使用init.groovy.d脚本,但是:

  • 是最好的选择吗?
  • 有没有办法阻止这些脚本在第二次启动时再次运行? (我不想在init之后覆盖任何更改)

1 个答案:

答案 0 :(得分:0)

我最终使用文件作为状态标记

#test file is the file that contain my words
open( my $words, '<:utf8', 'test' ) or die "Unable to open for read: $!";   

#sentences fila that contain one sentence per line
open( my $sentences, '<:utf8', 'sentences' ) or die "Unable to open for read: $!"; 
open my $fh_resultat, ">:utf8", 'result';
my $word;

#i want to calculate the number of sentences from my $sentences that containe word from my file $words

#load sentences into memory
my @process;
while ( $line = <$sentences> ) {
    push (@process, $line );
}
close(sentences);

while( defined( $word = <$words> ) ) {
    chomp $word ;
    $word =~ s/^\s*|\s*$//g;
    my $nb = 0;
    my $idf;
    my $ph;

    for $ph (@process) {
        my @tab = split(/ /, $ph);
        chomp @tab ;
        foreach my $val(@tab) {
            if($word eq $val){
                $nb = $nb + 1;
                last;
            }
        }
    }
    print $fh_resultat "$word:$nb\n";
}

它在脚本第一次运行时创建一个文件,它会检查文件是否存在并阻止执行第二个文件。