status-react/ci/Jenkinsfile.nix-cache

104 lines
2.7 KiB
Plaintext

pipeline {
agent { label params.AGENT_LABEL }
environment {
/* See nix/README.md */
NIX_IGNORE_SYMLINK_STORE = 1
/* we source .bash_profile to be able to use nix-store */
NIX_SSHOPTS = "-o StrictHostKeyChecking=no source .bash_profile;"
/* where our /nix/store is hosted */
NIX_CACHE_USER = 'nix-cache'
NIX_CACHE_HOST = 'master-01.do-ams3.ci.misc.statusim.net'
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
}
options {
timestamps()
disableConcurrentBuilds()
/* Prevent Jenkins jobs from running forever */
timeout(time: 300, unit: 'MINUTES')
/* Limit builds retained */
buildDiscarder(logRotator(
numToKeepStr: '20',
daysToKeepStr: '30',
))
}
stages {
stage('Prep') {
steps { script {
nix = load('ci/nix.groovy')
} }
}
stage('Setup') {
steps { script {
sh 'scripts/setup'
nix.shell('nix-env -i openssh', pure: false)
} }
}
stage('Build status-go') {
steps { script {
['android', 'desktop', 'ios'].each { os ->
nix.build(
attr: "targets.status-go.${os}.buildInputs",
args: ['target-os': 'all'],
link: false
)
}
} }
}
stage('Build android jsbundle') {
steps { script {
/* build/fetch things required to produce a js-bundle for android
* (e.g. maven and node repos) */
nix.build(
attr: 'targets.mobile.jsbundle',
args: ['target-os': 'android'],
pure: false,
link: false
)
} }
}
stage('Build android deps') {
steps { script {
/* build/fetch things required to build jsbundle and android */
nix.build(
attr: 'targets.mobile.android.buildInputs',
args: ['target-os': 'android'],
pure: false,
link: false
)
} }
}
stage('Build nix shell deps') {
steps { script {
/* build/fetch things required to instantiate shell.nix for TARGET_OS=all */
nix.build(
attr: 'shell',
args: ['target-os': 'all'],
link: false
)
} }
}
stage('Upload') {
steps { script {
sshagent(credentials: ['nix-cache-ssh']) {
nix.shell("""
find /nix/store/ -mindepth 1 -maxdepth 1 -type d \
-not -name '*.links' -and -not -name '*-status-react-*' \
| xargs nix-copy-closure -v --to ${NIX_CACHE_USER}@${NIX_CACHE_HOST}
""",
pure: false
)
}
} }
}
}
post {
always { script {
nix.shell('nix-store --optimize', pure: false)
nix.shell('nix/clean.sh', pure: false)
} }
}
}