red888
red888

Reputation: 31540

jenkins job dsl trigger not working for freestyle job

I want to create a freestyle job that runs every minute. I can get it to work with "triggers" not sure what the issue is

job('myjob') {

    // doesnt throw error and doesnt configure trigger
    //triggers { cron "* * * *" }

    // throws error when running
    //triggers { periodic(1) }

    // this works but I want 1 minute not 2 minutes
    // the correct syntax in the UI is just "* * * *" but dsl doesnt seem to like that
    //triggers { cron "H/2 * * * *" }

    steps {
        systemGroovyCommand(""" 
            jenkins.model.Jenkins.instance.getAllItems(jenkins.model.ParameterizedJobMixIn.ParameterizedJob.class).findAll{
              println it
            }
        """)
    }

Upvotes: 0

Views: 446

Answers (2)

Pankaj Saini
Pankaj Saini

Reputation: 1648

it seems you missed one element, it needs to be 5 elements if it is cron entry.

triggers {
        cron('* * * * *')
    }

Upvotes: 0

Alex O
Alex O

Reputation: 8164

Cron entries must contain five elements. The proper syntax is

triggers { cron("* * * * *") }

Upvotes: 0

Related Questions