don't go into android dir, copy results if not linking

Signed-off-by: Jakub Sokołowski <jakub@status.im>
Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
This commit is contained in:
Jakub Sokołowski 2019-08-26 12:56:55 -04:00 committed by Pedro Pombeiro
parent b0dc2dd4f5
commit 17407b3680
No known key found for this signature in database
GPG Key ID: C4A24185B2AA48A1
3 changed files with 44 additions and 38 deletions

View File

@ -20,42 +20,41 @@ def bundle() {
} }
// The Nix script cannot access the user home directory, so best to copy the file to the Nix store and pass that to the Nix script // The Nix script cannot access the user home directory, so best to copy the file to the Nix store and pass that to the Nix script
dir('android') { withCredentials([
withCredentials([ string(
string( credentialsId: 'android-keystore-pass',
credentialsId: 'android-keystore-pass', variable: 'STATUS_RELEASE_STORE_PASSWORD'
variable: 'STATUS_RELEASE_STORE_PASSWORD' ),
), usernamePassword(
usernamePassword( credentialsId: 'android-keystore-key-pass',
credentialsId: 'android-keystore-key-pass', usernameVariable: 'STATUS_RELEASE_KEY_ALIAS',
usernameVariable: 'STATUS_RELEASE_KEY_ALIAS', passwordVariable: 'STATUS_RELEASE_KEY_PASSWORD'
passwordVariable: 'STATUS_RELEASE_KEY_PASSWORD' )
) ]) {
]) { nix.build(
nix.build( args: [
args: [ 'gradle-opts': gradleOpt,
'gradle-opts': gradleOpt, 'build-number': utils.readBuildNumber(),
'build-number': utils.readBuildNumber(), 'build-type': btype
'build-type': btype ],
], safeEnv: [
safeEnv: [ 'STATUS_RELEASE_KEY_ALIAS',
'STATUS_RELEASE_KEY_ALIAS', 'STATUS_RELEASE_STORE_PASSWORD',
'STATUS_RELEASE_STORE_PASSWORD', 'STATUS_RELEASE_KEY_PASSWORD'
'STATUS_RELEASE_KEY_PASSWORD' ],
], keep: [
keep: [ 'REALM_DISABLE_ANALYTICS', 'NDK_ABI_FILTERS',
'REALM_DISABLE_ANALYTICS', 'NDK_ABI_FILTERS', 'STATUS_RELEASE_STORE_FILE'
'STATUS_RELEASE_STORE_FILE' ],
], sbox: [
sbox: [ env.STATUS_RELEASE_STORE_FILE
env.STATUS_RELEASE_STORE_FILE ],
], attr: 'targets.mobile.android.release',
attr: "targets.mobile.android.release" link: false
) )
}
} }
/* because nix-build was run in `android` dir that's where `result` is */ /* because nix-build was run in `android` dir that's where `result` is */
def outApk = "android/result/app.apk" def outApk = "result/app.apk"
def pkg = utils.pkgFilename(btype, 'apk') def pkg = utils.pkgFilename(btype, 'apk')
/* rename for upload */ /* rename for upload */
sh "cp ${outApk} ${pkg}" sh "cp ${outApk} ${pkg}"

View File

@ -59,7 +59,7 @@ def build(Map opts = [:]) {
opts.args = defaults.args + opts.args opts.args = defaults.args + opts.args
opts.keep = (opts.keep + defaults.keep).unique() opts.keep = (opts.keep + defaults.keep).unique()
return sh( def resultPath = sh(
returnStdout: true, returnStdout: true,
script: """ script: """
set +x set +x
@ -68,6 +68,10 @@ def build(Map opts = [:]) {
nix-build ${_getNixCommandArgs(opts, false)} nix-build ${_getNixCommandArgs(opts, false)}
""" """
).trim() ).trim()
if (!opts.link) { /* if not linking, copy results */
sh "cp ${resultPath}/* ${env.WORKSPACE}/result/"
}
return resultPath
} }
private makeNixBuildEnvFile(Map opts = [:]) { private makeNixBuildEnvFile(Map opts = [:]) {

View File

@ -2,6 +2,9 @@
set -e set -e
gitRoot=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
resultPath="${gitRoot}/result/"
# cleanup for artifacts created during builds # cleanup for artifacts created during builds
function cleanup() { function cleanup() {
# clear trapped signals # clear trapped signals
@ -24,9 +27,9 @@ trap cleanup EXIT ERR INT QUIT
function extractResults() { function extractResults() {
local nixResultPath="$1" local nixResultPath="$1"
echo "Saving build result: ${nixResultPath}" echo "Saving build result: ${nixResultPath}"
mkdir -p result mkdir -p "${resultPath}"
cp -vfr ${nixResultPath}/* result/ cp -vfr ${nixResultPath}/* "${resultPath}"
chmod u+w -R result/ chmod u+w -R "${resultPath}"
} }
# Load Nix profile # Load Nix profile