Problem with cron

I have configured a cron job * * * 1,15 * * on master and it not work. I have the following errors in log:

Dec 01 01:21:37 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T00:21:37Z"}
Dec 01 01:51:37 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T00:51:37Z"}
Dec 01 02:21:37 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T01:21:37Z"}
Dec 01 02:51:37 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T01:51:37Z"}
Dec 01 03:21:37 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T02:21:37Z"}
Dec 01 03:51:37 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T02:51:37Z"}
Dec 01 04:21:37 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T03:21:37Z"}
Dec 01 04:51:37 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T03:51:37Z"}
Dec 01 05:21:38 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T04:21:38Z"}
Dec 01 05:51:38 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T04:51:38Z"}
Dec 01 06:21:38 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T05:21:38Z"}
Dec 01 06:51:38 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T05:51:38Z"}
Dec 01 07:21:38 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T06:21:38Z"}
Dec 01 07:51:38 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T06:51:38Z"}
Dec 01 08:21:38 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T07:21:38Z"}
Dec 01 08:51:38 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T07:51:38Z"}
Dec 01 09:21:38 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T08:21:38Z"}
Dec 01 09:51:38 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T08:51:38Z"}
Dec 01 10:21:38 fialka docker[944]: {"branch":"master","cron":1,"error":"Not Supported","level":"warning","msg":"cron: cannot find commit","repo":"ogarcia/docker-archlinux","time":"2018-12-01T09:21:38Z"}

Any clues that what is happend?

It seems you’re configuring seconds – does Drone support that? (I don’t know). Have you tried * * 1,15 * * which means “at every minute on the day 1 and 15 of the month”?

It seems you’re configuring seconds – does Drone support that

Yes, the cron parser we are using requires seconds, actually (which is sort of annoying)

This particular error does not appear to be an error with the cron expression. Instead, it looks like the API call to get the latest commit for your branch is returning an error. When you setup cron did you provide a branch? And does that branch exist? Also if you are using Gogs or Gitea please be advised that you cannot use cron, because Gogs and Gitea do not expose API endpoints for getting the latest commit for a branch.

Misery solved. I’m using Gogs. @bradrydzewski do you send a feature request in Gogs asking for this endpoint? Is to add me to issue tracking.

@davidbyttow Yes the cron is misformatted, must be 0 0 0 1,15 * * :smiley:

@ogarcia I have not, but we basically need two endpoints from gogs. First we need the ability to get the branch information (which provides us a commit sha) and we also need an endpoint to get the commit details by sha. These are the equivalent endpoints (if you want to open an issue with Gogs)

Done: https://github.com/gogs/gogs/issues/5546

@bradrydzewski reading about current implemented API in Gogs/Gitea there is an endpoint to get latest commit of a branch:
/api/v1/repos/:user/:repo/branches/:branch

It returns some like this:

{
  "name": "master",
  "commit": {
    "id": "f650b4271b6482c0a1fec1f5f5ef2d4a6b5e29b8",
    "message": "Point .drone.yml to ogarcia/archlinux\n",
    "url": "Not implemented",
    "author": {
      "name": "Óscar García Amor",
      "email": "my@beautiful.mail",
      "username": "ogarcia"
    },
    "committer": {
      "name": "Óscar García Amor",
      "email": "my@beautiful.mail",
      "username": "ogarcia"
    },
    "added": null,
    "removed": null,
    "modified": null,
    "timestamp": "2018-11-21T15:16:02+01:00"
  }
}

The id is the sha of latest commit from the branch.

the endpoint works with gitea, but I am not able to get it working with gogs version 0.11.75.1203

I have installed latest stable version of Gogs (0.11.66.0916) and works well. Anyway I make for you a drone account (same password) in https://try.gogs.io (latest develop version) for the tests, can be deleted or destroyed.

If you do curl -H "Authorization: token e91a70592aafd6ef33eb6de3cd203acbcc6d48cf" https://try.gogs.io/api/v1/repos/drone/awesome-project/branches you can get all branches with its latest commit.

If you do curl -H "Authorization: token e91a70592aafd6ef33eb6de3cd203acbcc6d48cf" https://try.gogs.io/api/v1/repos/drone/awesome-project/branches/master you can get the master branch or curl -H "Authorization: token e91a70592aafd6ef33eb6de3cd203acbcc6d48cf" https://try.gogs.io/api/v1/repos/drone/awesome-project/branches/devel for devel brach.

Is important to be authenticated to gain access to API.

I was wrong, this is the endpoint that is missing from gogs and gitea: https://developer.github.com/v3/repos/commits/#get-a-single-commit

Specifically they provide two variants of the endpoint, both of which are used by Drone:

GET /repos/:owner/:repo/commits/:sha
GET /repos/:owner/:repo/commits/:ref

@bradrydzewski change is made in latest devel version of Gogs. Can you try it in https://try.gogs.io?

The docs: https://github.com/gogs/docs-api/blob/master/Repositories/Commits.md

More info in the issue: https://github.com/gogs/gogs/issues/5546

that is great. I have created an issue to track: https://github.com/drone/go-scm/issues/7