Parnash
Parnash

Reputation: 9

Run Jenkins file from particular folder

I have created new jenkins job, in which I want to execute a Jenkins file from a particular folder.

I have created one folder in my project named pipelinescript, in which I have placed my Jenkinsfile.

But when I am executing that job the file has not been detected.

In script path I have also give /pipelinescript/Jenkinsfile, but it is not working.

Upvotes: 1

Views: 5071

Answers (3)

Michael J
Michael J

Reputation: 1553

A few things to consider:

  1. Is your new job a freestyle job? If so, you may have some trouble calling the Jenkinsfile at all. You should be using a Pipeline job to use the Jenkinsfile approach.
  2. When you define your Pipeline job, the path the to Jenkinsfile is relative to the workspace. So to reference the Jenkinsfile in the subdirectory, you would need to configure the path like 'pipelinescript/Jenkinsfile'. Here's a screenshot of the Pipeline job configuration form:

enter image description here

Upvotes: 1

SV Madhava Reddy
SV Madhava Reddy

Reputation: 2018

First of all jenkins whichever files are picking up, all are workspace related. If you refer a path with no / in front of it, then it will load it from workspace only. To load a jenkins file from a custom location, you have to do like this by adding this line to the script.

load "/<custom path here>/Jenkinsfile"

For more info, please refer this.

Upvotes: 0

Ankit
Ankit

Reputation: 88

Instead of mentioning /pipelinescript/Jenkinsfile please use the entire absolute path. It will resolve the issue.

Upvotes: 0

Related Questions