HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Is there a way to run the Jenkinsfile from command line?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
fromthelinewayjenkinsfilecommandthererun

Problem

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.

Solution

I've done this before. Essentially you can use the 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 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.

Context

StackExchange DevOps Q#3685, answer score: 3

Revisions (0)

No revisions yet.