2019-02-28 10:56:58 +00:00
|
|
|
pipeline {
|
|
|
|
agent {
|
|
|
|
/* the -u is necessary for acces to /nix */
|
|
|
|
docker {
|
|
|
|
label 'linux'
|
2019-04-03 11:06:42 +00:00
|
|
|
image 'statusteam/nix:jenkins-1.0.0-e20e5e15'
|
2019-02-28 10:56:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
environment {
|
2019-04-03 11:06:42 +00:00
|
|
|
CI_ENVIRONMENT = 'jenkins'
|
2019-02-28 10:56:58 +00:00
|
|
|
/* we source .bash_profile to be able to use nix-store */
|
2019-04-02 20:27:01 +00:00
|
|
|
NIX_SSHOPTS = "-o StrictHostKeyChecking=no source .bash_profile;"
|
2019-02-28 10:56:58 +00:00
|
|
|
/* where our /nix/store is hosted */
|
|
|
|
NIX_CACHE_USER = 'nix-cache'
|
|
|
|
NIX_CACHE_HOST = 'master-01.do-ams3.ci.misc.statusim.net'
|
2019-04-03 11:06:42 +00:00
|
|
|
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
|
2019-02-28 10:56:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
options {
|
|
|
|
timestamps()
|
|
|
|
disableConcurrentBuilds()
|
|
|
|
/* Prevent Jenkins jobs from running forever */
|
|
|
|
timeout(time: 20, unit: 'MINUTES')
|
|
|
|
/* Limit builds retained */
|
|
|
|
buildDiscarder(logRotator(
|
|
|
|
numToKeepStr: '20',
|
|
|
|
daysToKeepStr: '30',
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
|
|
|
stage('Setup') {
|
|
|
|
steps {
|
|
|
|
sh 'nix-env -i openssh'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Build') {
|
|
|
|
steps {
|
2019-04-03 11:06:42 +00:00
|
|
|
sh """
|
|
|
|
nix build --no-link &&
|
|
|
|
nix-shell --run echo
|
|
|
|
"""
|
2019-02-28 10:56:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Upload') {
|
|
|
|
steps {
|
|
|
|
sshagent(credentials: ['nix-cache-ssh']) {
|
|
|
|
sh """
|
|
|
|
find /nix/store/ -mindepth 1 -maxdepth 1 -not -name '.links' -and -not -name '*.lock' | \
|
|
|
|
xargs nix-copy-closure -v --to ${NIX_CACHE_USER}@${NIX_CACHE_HOST}
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|