https://github.com/couchbaselabs/sdkbuild-jenkinsfiles/blob/0635c577505378b1106880548685823c93fce39b/python/python-scripted-build-pipeline.groovy#L676
is a good starting point.