oc123456
oc123456

Reputation: 61

Execute Jenkinsfile from filesystem

disclaimer: I'm new to Jenkins.

I am working on a Jenkins that must be runnable locally. The goal is to be able to edit our jobs and test them locally before pushing our changes to the 'real' Jenkins.

We work with Jenkinsfile and job-DSL (don't know if this matters).

I would like to be able to edit my Jenkinsfile locally, then go to my localhost:8080 and tell Jenkins to execute this Jenkinsfile to update our jobs.

First, I would force Jenkins to read the new Jenkinsfile. I think this is doable with a kind of a job (I suppose).

Then, I would like to also run a watcher on job files (.groovy, .dsl and Jenkinsfile) to trigger the update.

I know how to retrieve Jenkinsfile from SCM so that Jenkins can take care of everything but I don't know how to execute a Jenkinsfile that already is on the same filesystem than Jenkins, inside the jenkins_home (I can put it anywhere although).

I'm pretty sure this question is kind of stupid but I can't achieve this.

note:

I know that Jenkinsfile seems to be used only while using SCM, as the documentation says so. But when you create a pipeline using the UI, you are writing a Jenkinsfile (right?) so it should be possible to trigger the same functions used when Jenkins interpret your pipeline created through the UI.

Upvotes: 2

Views: 5612

Answers (3)

Deep Panda
Deep Panda

Reputation: 86

Use File Scm plugin to select a local jenkins file.

Upvotes: 2

oc123456
oc123456

Reputation: 61

Thanks to JustAProgrammer and Holleoman, I understand that there is no way to do that properly.

Jenkins is build to interact with a SCM, doing all the things locally seems to make nonsense or is not the Jenkins way of thinking.

I'm closing this question for now !

Thanks.

Upvotes: 2

Holleoman
Holleoman

Reputation: 269

I decided to have on job where I have a pipeline script, which I edit directly. A second job which checks out my feature branch. And a production job which checks out the master branch.

So I can experiment without messing up my git repo to much.

Upvotes: 0

Related Questions