teamhephy / jenkins-jobs

MIT License
0 stars 3 forks source link

Capture boilerplate shell contents in reusable function #12

Open Cryptophobia opened 6 years ago

Cryptophobia commented 6 years ago

From @vdice on August 24, 2016 20:36

We have a lot of shell scripts in the form of

#!/usr/bin/env bash
set -eo pipefail

<main script contents>

It would be handy to define a function that wrapped the <main script contents> in the boilerplate seen above; something like:

def sh = { String script ->
  """
    #!/usr/bin/env bash

    set -eo pipefail

    ${script}
  """.stripIndent()
}

(Might possibly entertain overriding the existing shell dsl function to do the same.)

Copied from original issue: deis/jenkins-jobs#214