<p>I've done this before. Essentially you can use the <a href="https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI" rel="nofollow noreferrer">Jenkins CLI</a> to import/export jobs, which will allow you to create and/or update a job with the definition you want to run. Be it JenkinsFile or some groovy script or whatever. Check this <a href="http://lifuzu.com/blog/2014/04/24/playing-with-jenkins-create-job/" rel="nofollow noreferrer">blog</a> for details.</p>

<p>Once you (re)define the job, you will simply remotely execute it using the same Jenkins CLI. You can check the progress of the job from CLI and even read the logs to see progress. I cannot share the code, as the copyright is owned by one of my previous employers, but it is easy to recreate.</p>

CC BY-SA 4.0
2018-08-05T18:50:02.110Z
2018-08-05T18:50:02.110Z
Jiri Klouda
<p>I assume you would like to run locally to test logic? If so there is a <a href="https://github.com/jenkinsci/JenkinsPipelineUnit" rel="nofollow noreferrer">unit testing framework</a> for Jenkins declarative / scripted pipeline. I have not personally used it but this would enable me to test stubbed logic locally.</p>

<p>Alternatively, as you're no ta fan of GUIs you could have a look at <a href="https://jenkins.io/blog/2018/03/19/introducing-jenkins-x/" rel="nofollow noreferrer">Jenkins X</a> which has a very powerful CLI and is more gitops driven.</p>

CC BY-SA 4.0
2018-08-05T15:40:50.750Z
2018-08-05T15:40:50.750Z
Robert
<p>you can try using that tool, it allows to run scripts from the command line and some other thinkgs:</p>
<p><a href="https://github.com/jenkinsci/jenkinsfile-runner" rel="nofollow noreferrer">https://github.com/jenkinsci/jenkinsfile-runner</a></p>

CC BY-SA 4.0
2021-11-09T11:20:06.307Z
2021-11-09T11:20:06.307Z
igreenfield
<p>I don't want to use Jenkins UI, instead I would like to use the command line, from command line I want to execute Jenkinsfile to the Jenkins server.</p>

<p>Is this possible?</p>

<p>Let's say I have a Jenkinsfile, If I run the Jenkinsfile, It shoud execute the Jenkinsfile from Jenkins server. Assume that the job not yet configured through Jenkins UI. </p>

CC BY-SA 3.0
2018-03-21T05:44:04.927Z
What about calling the Jenkins api using the jenkins-cli?
030
CC BY-SA 3.0
2018-03-22T15:33:47.177Z
Why do you need this? Why does the UI not work for you?
030
CC BY-SA 3.0
2018-03-22T21:14:32.740Z
@030 I'm not a fan of GUI :)
Buvanesh Kumar
CC BY-SA 3.0
2018-03-22T23:44:38.347Z
Interesting. Jenkins itself is a UI, but if you really dislike UIs then one could use the jenkins-cli.
030
CC BY-SA 4.0
2018-07-20T19:42:39.103Z
I am interested in this for testing purposes and cross-compatibility. I'd like to be able to have automatic builds based on regular multibranch/jenkinsfile plus parameterized GUI jobs when we need a manual tweak plus local CLI terminal scripts for devs to verify their part.
AnneTheAgile
<jenkins-pipeline><jenkins-plugins><jenkinsfile><jenkins2>
Is there a way to run the Jenkinsfile from command line?
Buvanesh Kumar
# Is there a way to run the Jenkinsfile from command line?

(Asked by: username_0 on 2018-03-21)

I don't want to use Jenkins UI, instead I would like to use the command line, from command line I want to execute Jenkinsfile to the Jenkins server.

Is this possible?

Let's say I have a Jenkinsfile, If I run the Jenkinsfile, It shoud execute the Jenkinsfile from Jenkins server. Assume that the job not yet configured through Jenkins UI.

**Tags:** jenkins-pipeline, jenkins-plugins, jenkinsfile, jenkins2

> **Comments:**
> **username_1**: What about calling the Jenkins api using the jenkins-cli?  
> **username_1**: Why do you need this? Why does the UI not work for you?  
> **username_0**: @username_1 I'm not a fan of GUI :)  
> **username_1**: Interesting. Jenkins itself is a UI, but if you really dislike UIs then one could use the jenkins-cli.  
> **username_2**: I am interested in this for testing purposes and cross-compatibility. I'd like to be able to have automatic builds based on regular multibranch/jenkinsfile plus parameterized GUI jobs when we need a manual tweak plus local CLI terminal scripts for devs to verify their part.  

---

## 3 answers

### Answer by username_3 on 2018-08-05. Score: 3

I've done this before. Essentially you can use the [Jenkins CLI](https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI) to import/export jobs, which will allow you to create and/or update a job with the definition you want to run. Be it JenkinsFile or some groovy script or whatever. Check this [blog](http://lifuzu.com/blog/2014/04/24/playing-with-jenkins-create-job/) for details.

Once you (re)define the job, you will simply remotely execute it using the same Jenkins CLI. You can check the progress of the job from CLI and even read the logs to see progress. I cannot share the code, as the copyright is owned by one of my previous employers, but it is easy to recreate.


---

### Answer by username_4 on 2018-08-05. Score: 2

I assume you would like to run locally to test logic? If so there is a [unit testing framework](https://github.com/jenkinsci/JenkinsPipelineUnit) for Jenkins declarative / scripted pipeline. I have not personally used it but this would enable me to test stubbed logic locally.

Alternatively, as you're no ta fan of GUIs you could have a look at [Jenkins X](https://jenkins.io/blog/2018/03/19/introducing-jenkins-x/) which has a very powerful CLI and is more gitops driven.


---

### Answer by username_5 on 2021-11-09. Score: 0

you can try using that tool, it allows to run scripts from the command line and some other thinkgs:

<https://github.com/jenkinsci/jenkinsfile-runner>


---

