From 7c7eb0ba3dafc9a36e847fc0220969431ace00ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 28 Aug 2019 11:39:27 -0400 Subject: [PATCH] clean results before copying them from Nix store MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- ci/nix.groovy | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ci/nix.groovy b/ci/nix.groovy index 6378e2b796..ed9df98055 100644 --- a/ci/nix.groovy +++ b/ci/nix.groovy @@ -59,7 +59,7 @@ def build(Map opts = [:]) { opts.args = defaults.args + opts.args opts.keep = (opts.keep + defaults.keep).unique() - def resultPath = sh( + def nixPath = sh( returnStdout: true, script: """ set +x @@ -68,10 +68,19 @@ def build(Map opts = [:]) { nix-build ${_getNixCommandArgs(opts, false)} """ ).trim() - if (!opts.link) { /* if not linking, copy results */ - sh "cp ${resultPath}/* ${env.WORKSPACE}/result/" + /* if not linking, copy results, but only if there's just one path */ + if (!opts.link && nixPath && !nixPath.contains('\n')) { + copyResults(nixPath) } - return resultPath + return nixPath +} + +private def copyResults(path) { + def resultsPath = "${env.WORKSPACE}/result" + sh "rm -fr ${resultsPath}" + sh "mkdir -p ${resultsPath}" + sh "cp -fr ${path}/* ${resultsPath}/" + sh "chmod -R 755 ${resultsPath}" } private makeNixBuildEnvFile(Map opts = [:]) {