2

I am trying to use the below command in Jenkins pipeline in Groovy Sandbox.

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

While the command runs properly if executed from windows cmd, but throws below error while executing in a Jenkins stage.

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

Below is the Jenkins stage snippet :

        stage ('Test') {            
        agent {label 'Jenkins_Label'}           
        steps{          
            bat """             
    cleartool describe -fmt "%[rec_bls]CXp" stream:stream_name@\\vob_name
         """            
         }
       }
Shivani
  • 219
  • 1
  • 14

2 Answers2

1

Check first if this is because of the -fmt "%[rec_bls]CXp", whose quotes are incorrectly interpreted in the Jenkins bat shell session.

For instance:

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

If that works, try and see how to add those quotes.
For instance:

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

If the '%' is the issue, escape it:

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

That will prevent the bat session to interpret it as a variable environment.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The command " cleartool describe -l stream:stream_name@\\vob_name" worked. It seems the issue is with % which is being used. cleartool describe -fmt """%[rec_bls]CXp""" stream:stream_name@\\vob_name and cleartool describe -fmt \"%[rec_bls]CXp\" stream:stream_name@\\vob_name , both result in the same error as mentioned above. – Shivani Dec 10 '19 at 14:04
1

I found a solution to it. Using %% solves the problem!

cleartool describe -fmt \"%%[rec_bls]CXp\" stream:stream_name@\\vob_name
Shivani
  • 219
  • 1
  • 14