Defining jenkinsfile script path when creating pipeline

13,142

Solution 1

From Jenkins site,

In the Script Path field, specify the location (and name) of your Jenkinsfile. This location is the one that Jenkins checks out/clones the repository containing your Jenkinsfile, which should match that of the repository’s file structure. The default value of this field assumes that your Jenkinsfile is named "Jenkinsfile" and is located at the root of the repository.

Jenkinsfile should be committed to SCM and put the relative path of the Jenkinsfile in SCM repository root. Careful on the name(Jenkinsfile or JenkinsFile)!

Solution 2

The Script Path is the relative location of your Jenkinsfile in the git repository (OR in the agent's workspace directory). so if the Jenkinsfile lives in /git-repository/your-project/folder1 then the Script Path should be: folder1/Jenkinsfile

Solution 3

In this case , you can keep your jenkins file into the existing workspace location

<<Jenkins-Installation-Dir>>/workspace/<<Job-Name>>
Share:
13,142
dhrDatt
Author by

dhrDatt

Hi, my name is Any Key. Please don't hit me!

Updated on June 29, 2022

Comments

  • dhrDatt
    dhrDatt over 1 year

    I want to checkout my repository from github.I create a pipeline and chose Here are the steps that I followed

    1. Click on new item on jenkins main page
    2. Entered name and chose pipeline form list
    3. Under Pipeline I chose definition as Pipeline script from SCM
    4. Chose SCM as GIT
    5. Under Repository entered the Repository Url with the credentials
    6. Under Branches to build entered by branch as */my_branch_here enter image description here

    Now the jenkisfile does not belong in the root directory.Is there a way to naviagate to the directory using jenkins UI

    • Snowcrash
      Snowcrash about 2 years
      Where is the documentation for this? Looking at plugins.jenkins.io/git I don't see any reference to scriptPath (as used in the Job DSL).
  • dhrDatt
    dhrDatt over 5 years
    I still get this error java.io.FileNotFoundException.What is usually the jenkins installation directory.I tried using C:/Program Files (x86)/Jenkins
  • Balakrishnan
    Balakrishnan over 5 years
    Jenkins installation directory means where you installed the current jenkins. Hope you installed jenkins in your windows machine. You may keep jenkins-file in this location and try to execute "C:/Program Files (x86)/Jenkins/Workspace/<<YOur Job Name>>"
  • dhrDatt
    dhrDatt over 5 years
    Is there a way to refresh the workspace.I cannot see the file in the folder
  • Balakrishnan
    Balakrishnan over 5 years
    It won't be available intiially, you have to create and put the JenkinsFile in that location. Else you have to commit the same file in GIT repo. so next time if you are running the job it will take the file from your project repo.
  • dhrDatt
    dhrDatt over 5 years
    Stil doesn't work.I tried creating the file directly also tried pushing to the git repository.I can only get it to work when it is in the root folder