I want to use following Pipeline script from git in jenkins
#!groovy
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building..'
}
}
stage('Test') {
steps {
echo 'Testing..'
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
}
}
}
}
I set the Repository URL right, under "Additional Behaviors" i added "Check out to a sub-directory" and wrote my sub directory there.
At "Script-Path" I wrote: mysubdirectory/Jenkinsfile
When I try to run it I get following ERROR:
java.io.FileNotFoundException
at jenkins.plugins.git.GitSCMFile$3.invoke(GitSCMFile.java:167)
at jenkins.plugins.git.GitSCMFile$3.invoke(GitSCMFile.java:159)
at jenkins.plugins.git.GitSCMFileSystem$3.invoke(GitSCMFileSystem.java:162)
at org.jenkinsci.plugins.gitclient.AbstractGitAPIImpl.withRepository(AbstractGitAPIImpl.java:29)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.withRepository(CliGitAPIImpl.java:71)
at jenkins.plugins.git.GitSCMFileSystem.invoke(GitSCMFileSystem.java:158)
at jenkins.plugins.git.GitSCMFile.content(GitSCMFile.java:159)
at jenkins.scm.api.SCMFile.contentAsString(SCMFile.java:338)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:101)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:59)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:262)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:415)
Finished: FAILURE
What am I doing wrong?
How can I run a Jenkins Script from git correctly?
To run the Jenkinsfile Successfully from Git repo Jenkinsfile should be available in main directory path,but not in the sub directory. For Example:
.
├── .setting
├── project
└── Jenkinsfile
Jenkinsfile should not be in the Sub Directory.