disable schedule (cron) job when failed (OD-2590)
bufferUnderrun opened 2 months ago

Hi Robin,

I hope you are doing well !

I've setup a cron job in Onedev which basically run a script inside a container. I also enable notification when my job failed, I receive email and sms notification.

But due to the nature of the cron job, once my script failed, I received a non stop notification cause the job is executed each 5min.

I would like that when the job is failed, it's disabled.

What about a new step "disable job" when condition "failed" for cron job ?

image_2.png

Thanks for you help

  • bufferUnderrun commented 2 months ago

    I found a workaround :

    • I've setup the job as a normal job trigger manually (not cron)
    • if the script is success, it uses the rest api to run the rerun the job itself

    I use the following REST API https://code.stratdev.fr/~help/api/io.onedev.server.rest.resource.JobRunResource/runBuild with parameters :

    var jobRun = new Dictionary<string, object>
    {
        ["@type"] = "JobRunOnCommit",
        ["projectId"] = 42,
        ["commitHash"] = "b9aeaefe32b133df775f0c65bd70cd17c0e1e123",
        ["jobName"] = "myjob",
        ["refName"] = "refs/heads/master",
        ["reason"] = "Triggered by dotnet script"
    };
    

    could it be possible to change the REST API so when the commitHash is missing, it takes the last commit (HEAD) ?

    Thanks

  • bufferUnderrun commented 2 months ago

    Note : this does not work as run a job inside the same job running do not rerun a new one.

    Any idea ?

  • Robin Shen commented 2 months ago

    Note : this does not work as run a job inside the same job running do not rerun a new one.

    This is by design. Convert as an improvement request

  • Robin Shen changed fields 2 months ago
    Name Previous Value Current Value
    Type
    Question
    Improvement
  • bufferUnderrun commented 2 months ago

    This is by design. Convert as an improvement request

    I found a workaround : I set a "random" string parameter to my job and then, I run the job with a new Guid() value in the parameter. So it "bypass" the single instance build for the same commit hash.

  • bufferUnderrun changed state to 'Closed' 2 months ago
    Previous Value Current Value
    Open
    Closed
  • Robin Shen commented 2 months ago

    I found a workaround : I set a "random" string parameter to my job and then, I run the job with a new Guid() value in the parameter. So it "bypass" the single instance build for the same commit hash.

    Yes this is a good idea

issue 1/1
Type
Improvement
Priority
Normal
Assignee
Labels
No labels
Issue Votes (0)
Watchers (2)
Reference
OD-2590
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover