Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to discover Jenkinsfile in subfolders

I have a project with two folders, that are independent, and needs separate builds in Jenkins (running v2.74)

My structure is

folder
├── project1
│   └── Jenkinsfile
└── project2
    └── Jenkinsfile

When I click "scan organization" in Jenkins, it doesnt discover the Jenkinsfiles in subdirectories.

Here is a sample from the "Scan organization log":

Proposing kg-pipeline
Examining my-test-project

  Checking branches...

  Getting remote branches...

    Checking branch jenkins
      ‘Jenkinsfile’ not found
    Does not meet criteria

    Checking branch master
      ‘Jenkinsfile’ not found
    Does not meet criteria

  2 branches were processed

Finished examining my-test-project

I didnt touch the configuration of the job that scans the organization and finds branches with Jenkinsfiles. Here is the current setting for the project

Jenkinsfile discoverability configuration

My question is: How do I configure Jenkins to see each folder individually? I am also interested in links to example projects set up this way.

like image 881
Jesper Rønn-Jensen Avatar asked Oct 12 '17 08:10

Jesper Rønn-Jensen


2 Answers

There is a simple solution.

  1. go to JENKINS_URL/job/JOB_NAME/configure
  2. under Build Configuration, select by Jenkinsfile for Mode
  3. under Script Path, set it to DIR_NAME/Jenkinsfile

For instance, if you had your Jenkinsfile inside a src directory, then you would set it to src/Jenkinsfile and Jenkins will be able to find the Jenkinsfile now

like image 99
Ray Kim Avatar answered Sep 19 '22 01:09

Ray Kim


Currently trying to set up the same thing - this might help, even though it's not a complete answer:

According to this you should be able to setup two Multibranch Pipeline Projects, each with the configuration Mode "by Jenkinsfile".

Support for using custom paths for the Jeninsfile was added in JENKINS-34561

like image 40
Martin Avatar answered Sep 20 '22 01:09

Martin