> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flexagon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Invoking Jenkins job from command line

> Here are some useful references. Note that until we enable Allow anonymous read access , the cli does not work for build. See Following examples are c

Here are some useful references.

* [http://www.scmgalaxy.com/tutorials/complete-guide-to-use-jenkins-cli-command-line/](http://www.scmgalaxy.com/tutorials/complete-guide-to-use-jenkins-cli-command-line/)

* [http://www.tsbakker.nl/jenkins.html](http://www.tsbakker.nl/jenkins.html)

* [https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI](https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI)

* [https://jenkins.io/doc/book/managing/cli/](https://jenkins.io/doc/book/managing/cli/)

Note that until we enable **Allow anonymous read access**, the cli does not work for build. See [https://stackoverflow.com/questions/30066657/jenkins-cant-find-the-job-when-build-job-why](https://stackoverflow.com/questions/30066657/jenkins-cant-find-the-job-when-build-job-why)

> [!TIP]
>
> 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>
```

![Image](https://mintcdn.com/flexagon-llc-ce77a95c/NkeZh5D-Nf8j_WaD/images/fd111/12596424864.png?fit=max\&auto=format\&n=NkeZh5D-Nf8j_WaD\&q=85\&s=34ed1fc307e208d5b60b9dbdb7ea5674)

# 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>
```

> [!TIP]
>
> This can be done from FlexDeploy unix shell plugin using the command below.
>
> * Details in blue need to be updated for your setup or job being invoked.
>
> * Add necessary inputs to a 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

![Image](https://mintcdn.com/flexagon-llc-ce77a95c/NkeZh5D-Nf8j_WaD/images/fd111/12596424861.png?fit=max\&auto=format\&n=NkeZh5D-Nf8j_WaD\&q=85\&s=8db236c36cb30ae6b29627a5839ea7ed)

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

![Image](https://mintcdn.com/flexagon-llc-ce77a95c/NkeZh5D-Nf8j_WaD/images/fd111/12596424867.png?fit=max\&auto=format\&n=NkeZh5D-Nf8j_WaD\&q=85\&s=64ecd0b5548945a0d2ff445af2eb7010)
