Drone 2.0: Make available build.Debug field to starlark (via ctx)

Hello!

Drone 2.0 has a neat feature of restarting build pipelines in debug mode. The new build will be started with DRONE_BUILD_DEBUG='true' environment variable available on each step. Unfortunately, this option is not visible in starlark script (.drone.star), so there is no way to depend on it.

I propose to add a field to ctx structure, called ctx.build.debug (see pull request). This would allow to use it like this:

def main(ctx):
  s = [
    {
      "name": "build",
      "image": "builder_image",
      "commands": [
        # build the binary
      ]
    }
  ]
  if ctx.build.debug:
    s += [
      {
        "name": "valgrind",
        "image": "valgrind_image",
        "commands": [
          # test it with valgrind
        ]
      }
    ]
  return [{
    "kind": "pipeline",
    "type": "docker",
    "name": "default",
    "steps": s
  }]

What do you think?

Regards,
Timofei

2 Likes