Invoking Jenkins job from command line

Here are some useful references.

It also seems that until we enable Allow anonymous read access, this cli does not work for build. See

Following examples are coded to wait till Job is completed and it pulls in console output as well. Also, it will be able to retrieve status by just looking at return code.

Here are some of the example of cli invocation.

Invoke Job without any parameters

java -jar jenkins-cli.jar -s http://<hostname>:8080 build ExecuteParameters1 -f -s -v --username auto --password <password>

Invoke Job with parameters

java -jar jenkins-cli.jar -s http://<hostname>:8080 build ExecuteParameters1 -f -s -v -p ORACLE_HOME=/tmp -p INPUT1=2 -p INPUT2=3 --username auto --password <password>

This can be done from FlexDeploy unix shell plugin using command below.

  • Details in blue need to be updated for your setup or job being invoked.
  • Add necessary inputs to FlexDeploy workflow and use the values in command below in place of INPUT1, INPUT2.
  • We are using JENKINS_URL, JENKINS_USERNAME, JENKINS_PASSWORD properties, which can be added to FlexDeploy workflow properties and values will be defined on Topology.

$JAVA_HOME/bin/java -jar /u01/jenkins/jenkins-cli.jar -s $FDJENKINS_URL build <Job Name> -f -s -v -p INPUT1=$WF_INP1 -p INPUT2=$WF_INP2 --username $FDJENKINS_USERNAME --password JENKINS_PASSWORD

Now let's check what was passed to Jenkins job and it matches our input parameters.

Now let's try to fail Jenkins job by passing wrong arguments. In this case, we will pass incorrect folder and job will fail.

The following macros are not currently supported in the footer:
  • style