Elias22
Elias22

Reputation: 11

Start Jenkins-Pipeline if file exists

Are there any possibilities to trigger my pipeline only, if there exists a special file in my filesystem.

So I want to start a new build on my pipeline at 9 p.m. But only, if there is the file run.xy on my filesystem.

Upvotes: 0

Views: 1288

Answers (1)

3sky
3sky

Reputation: 890

At your Build periodically in Build Triggers section add 0 21 * * *. And pipeline start by something like this:

def folder = new File( 'filepath' )

// If it does exist
if( folder.exists() ) {
    //run build
} else {
   println "File doesn't exist" 
}

Upvotes: 1

Related Questions