0

I would like to call the Jenkins CLI from a Jenkinsfile. I am thinking that I can use the shell directive and call the cli via the client jar. For example

sh 'java -jar /path/to/client.jar...' 

What I am unsure about is how to get the client jar. I could do something like a wget to fetch it, but is there a better way?

  • Could you please elaborate on why you want to use the client.jar? You can access the entire Jenkins Java API from a script block in a Declarative Jenkinsfile (or at any point in a Scripted Jenkinsfile), so there shouldn't be a need to shell out to the client.jar. – jayhendren Dec 27 '18 at 4:29
  • @jayhendren I want to call a cli function. In checking the cli documentation I did see a reference to calling commands from a Jenkinsfile script block. Is there an example of a cli command being called from a script block? – ssc327 Dec 27 '18 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.