如何在jenkins groovy中使用fmt_case?

问题描述 投票:1回答:2

我正在尝试在Groovy Sandbox的Jenkins管道中使用以下命令。

descr -fmt "%[rec_bls]CXp" stream:stream_name@\my_vob  

虽然从Windows cmd执行该命令可正常运行,但在Jenkins阶段执行该命令时将引发以下错误。

Running batch script    
path_to_workspace>cleartool describe -fmt 'stream_name@\my_vob
cleartool: Error: Object selector required.
Usage: describe -graphical pname …
...
…

下面是詹金斯舞台片段:

        stage ('Test') {            
        agent {label 'Jenkins_Label'}           
        steps{          
            bat """             
    cleartool describe -fmt "%[rec_bls]CXp" stream:stream_name@\\vob_name
         """            
         }
       }
jenkins groovy clearcase cleartool
2个回答
0
投票

我找到了解决方案。使用%%可以解决问题!

cleartool describe -fmt \"%%[rec_bls]CXp\" stream:stream_name@\\vob_name

0
投票

首先检查是否是由于-fmt "%[rec_bls]CXp"引起的,在詹金斯蝙蝠shell会话中其引号被错误地解释。

例如:

  stage ('Test') {            
    agent {label 'Jenkins_Label'}           
    steps{          
        bat """             
cleartool describe -l stream:stream_name@\\vob_name
     """            
     }
   }

如果可行,请尝试看看如何添加这些引号。例如:

cleartool describe -fmt """%[rec_bls]CXp""" stream:stream_name@\\vob_name
# or
cleartool describe -fmt \"%[rec_bls]CXp\" stream:stream_name@\\vob_name

如果是'%'的问题,请逃避它:

cleartool describe -fmt "%%[rec_bls]CXp" stream:stream_name@\\vob_name

这将阻止bat会话将其解释为可变环境。

© www.soinside.com 2019 - 2024. All rights reserved.