Background:

Step 1: Make sure that the pipeline only runs once concurrently.

This assures that when you schedule the pipeline to run e.g. all five minutes, and it takes 10 minutes to execute it, that only one pipeline is running concurrently. This is important when the pipeline is using external resources (e.g. a test server).

lockBehavior: unlockWhenFinished

Step 2: Make sure that the pipeline is only started manually (and not on commit)

By default, GoCD triggers a pipeline when there is a commit in the material. To prevent this pipeline from getting executed with each commit (you don't want this, you want to schedule it), put a manual approval in the first stage of your pipeline

approval: manual

Step 3: Set the scheduler

You can use a Quarz CRON expression, details are here.

timer:
  spec: "0 15 * ? * MON-FRI"
  onlyOnChanges: true

Step 4: Complete example

  nightly-projectname:
    lockBehavior: unlockWhenFinished
    group: MYGROUP
    timer:
      spec: "0 15 * ? * MON-FRI"
      onlyOnChanges: true
    materials:
      fedicam-puppet-git:
        git: ssh://git@XXXXXX:7999/XXXX/XXXX-puppet.git
    stages:
      - build:
          clean_workspace: true
          approval: manual
          jobs:
            build_job:
              tasks:
                - *deploy_tasks_anchor