Skip to content

Instantly share code, notes, and snippets.

@slide
Last active March 17, 2020 23:27
Show Gist options
  • Save slide/e38fc4adfe18e7ebe94aa6e53627344a to your computer and use it in GitHub Desktop.
Save slide/e38fc4adfe18e7ebe94aa6e53627344a to your computer and use it in GitHub Desktop.
def engine = new groovy.text.SimpleTemplateEngine()
def blOpts = readYaml text:'''
cmakeOpts: "-DCMAKE_INSTALL_PREFIX=${installDir}/${pkg.toLowerCase()} -DCMAKE_BUILD_TYPE=${pkg.toLowerCase()}"
package:
- "Debug"
- "Release"
'''
node {
def pkg = ''
stage('Cmake') {
def installDir = "${WORKSPACE}/bindir"
for (int i = 0; i < blOpts.package.size(); i++) {
pkg = blOpts.package[i]
def binding = [
installDir : installDir,
pkg : pkg
]
def template = engine.createTemplate(blOpts.cmakeOpts).make(binding)
cmkOpts = template.toString()
echo "pkg: ${pkg}"
echo "cmkOpts: ${cmkOpts}"
}
}
}
16:25:51 [Pipeline] {
16:25:51 [Pipeline] stage
16:25:51 [Pipeline] { (Cmake)
16:25:51 [Pipeline] echo
16:25:51 pkg: Debug
16:25:51 [Pipeline] echo
16:25:51 cmkOpts: -DCMAKE_INSTALL_PREFIX=/home/jenkins/workspace/Test/foo/bindir/debug -DCMAKE_BUILD_TYPE=debug
16:25:51 [Pipeline] echo
16:25:51 pkg: Release
16:25:51 [Pipeline] echo
16:25:51 cmkOpts: -DCMAKE_INSTALL_PREFIX=/home/jenkins/workspace/Test/foo/bindir/release -DCMAKE_BUILD_TYPE=release
16:25:51 [Pipeline] }
16:25:51 [Pipeline] // stage
16:25:51 [Pipeline] }
16:25:51 [Pipeline] // node
16:25:51 [Pipeline] End of Pipeline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment