v1beta
Double column
curl
API
CLI

Jobs /

Create cron job

Creates a new cron job

URL parameters

    • project

      string required

      ID of the project

Request attributes

  • object

    • name

      string required

      The name of the job.

      pattern
      ^[a-zA-Z0-9]+((-|\s)[a-zA-Z0-9]+)*$
      min length
      3
      max length
      20
    • description

      string

      A description of the job.

      pattern
      ^[a-zA-Z0-9.,?\s\\/'"()[\];`%^&*\-_:!]+$
      max length
      200
    • billing

      object required

      • deploymentPlan

        string required

        The ID of the deployment plan to use.

        pattern
        ^[A-Za-z0-9-]+$
    • backoffLimit

      integer required

      The number of attempts to rerun a job before it is marked as failed.

    • activeDeadlineSeconds

      integer

      The maximum amount of time, in seconds, for a job to run before it is marked as failed.

      min
      1
    • deployment

      (multiple options)

      Where to deploy the job from.

      • object

        Deploy from version control

        • vcs

          object required

          • projectUrl

            string required

            URL of the Git repo to build.

          • projectType

            string required

            The VCS provider to use.

            one of
            bitbucket, gitlab, github, self-hosted
          • vcsId

            string

            If projectType is self-hosted, the ID of the self-hosted vcs to use.

            pattern
            ^[A-Za-z0-9-]+\/[A-Za-z0-9-]+$
          • dockerFilePath

            string required

            The file path of the Dockerfile.

            pattern
            ^\/([a-zA-Z0-9-.]+\/)*[a-zA-Z0-9-.]+$
          • dockerWorkDir

            string required

            The working directory of the Dockerfile.

            pattern
            ^\/([a-zA-Z0-9-.]+\/)*[a-zA-Z0-9-.]*$
          • projectBranch

            string required

            The name of the branch to use.

        OR

      • object

        Deploy from an external image

        • external

          object required

          • registryProvider

            string required

            Registry provider hosting the external image

            one of
            dockerhub, gcr-eu, gcr-us, gitlab, github
          • privateImage

            boolean

            Does the image require authentication

          • imagePath

            string required

            Path of the external image excluding the hostname

          • credentials

            object

            Authentication credentials for the private image. Required if privateImage is `true`.

          OR

        • object

          Deploy from a Northflank build service

          • internal

            object required

            • internalId

              string

              Internal ID of the build service to deploy

              pattern
              ^[A-Za-z0-9-]+$
            • branch

              string

              Branch to deploy

            • buildSHA

              Commit SHA to deploy, or 'latest' to deploy the most recent commit

      • environment

        object

        An object containing the environment variables to set for the job.

        • buildArguments

          object

          An object containing the build arguments to set for the job.

          • schedule

            string required

            The cron timer scheduling when to run the job.

            pattern
            (@(annually|yearly|monthly|weekly|daily|hourly))|((((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ?){5})
          • concurrencyPolicy

            string required

            Whether this job should run when another instance of the job is already running. `allow` will enable multiple instances of this job to run. `forbid` will keep the current instance of the job running and stop a new instance from being run. `replace` will terminate any currently running instance of the job and start a new one.

            one of
            allow, forbid, replace

        Response attributes

        • object

          • jobType

            string required

            The type of the job created

          • jobId

            string required

            The internal ID of the newly created job

          • buildInitiated

            boolean required

            Whether the job will be built immediately

          • name

            string required

            The name of the newly created job.

          • description

            string

            The description of the newly created job.

        API
        CLI

        POST /v1beta/projects/{project}/jobs/cron

        Example request

        request body

        curl

        curl --header "Content-Type: application/json" \
          --header "Authorization: Bearer NORTHFLANK_API_TOKEN" \
          --request POST \
          --data '{"name":"Example Service","description":"A service description","billing":{"deploymentPlan":"nf-compute-20"},"backoffLimit":0,"activeDeadlineSeconds":600,"deployment":{"vcs":{"projectUrl":"https://github.com/northflank/gatsby-with-northflank","projectType":"github","dockerFilePath":"/Dockerfile","dockerWorkDir":"/","projectBranch":"master"}},"environment":{"variable1":"abcdef","variable2":"12345"},"buildArguments":{"variable1":"abcdef","variable2":"12345"},"schedule":"30 8 * * *","concurrencyPolicy":"forbid"}' \
          https://api.northflank.com/v1beta/projects/{project}/jobs/cron

        Example response

        200 OK

        Details about the newly created job.

        JSON

        {
          "jobType": "normal",
          "jobId": "new-job",
          "buildInitiated": true,
          "name": "New Job",
          "description": "This is a new job."
        }

        © 2021 Northflank Ltd. All rights reserved.

        TermsPrivacy

        contact@northflank.com