build-monero/Jenkinsfile

131 lines
3.7 KiB
Groovy

def version = ""
def nproc = ""
def debname = "monero"
def docker_tag = "latest"
def get_version() {
return sh(
script: "./version.sh",
returnStdout: true
).trim()
}
def get_nproc() {
return sh(
script: "nproc",
returnStdout: true
).trim()
}
pipeline {
agent any
options {
timestamps()
ansiColor("xterm")
disableConcurrentBuilds()
// skipDefaultCheckout()
buildDiscarder(
logRotator(
// daysToKeepStr: '15',
// artifactDaysToKeepStr: '15',
numToKeepStr:'30',
artifactNumToKeepStr: '1'
)
)
}
stages {
stage('checkout') {
steps {
checkout scm
script {
// update references of submodules
sh "git submodule sync"
sh "git config -f .gitmodules submodule.monero.branch release-v0.17"
// update the upstream monero repo (as a submodule)
sh "git submodule update --init --remote monero"
// pull in the submodules from the upstream monero
// repo (which is a submodule in our repo)
sh "git submodule update --init --recursive"
// used in lager stages
version = get_version()
nproc = get_nproc()
currentBuild.displayName += " -${version}"
currentBuild.description = params.build_mode
}
}
}
stage ('build monero') {
steps {
script {
sh "docker build --pull --build-arg NPROC=${nproc} --target builder -t monero:${version} ."
sh "docker container create --name monero_builder monero:${version}"
dir('build/release/bin/') {
sh "docker container cp monero_builder:/src/build/release/bin/ ."
}
dir('build/deb/') {
echo "no .deb file yet"
}
}
}
}
stage('build container') {
steps {
script {
sh "docker build --pull --build-arg VERSION=${version} --build-arg NPROC=${NPROC} monero:${version} ."
}
}
}
}
post {
success {
script {
archiveArtifacts(
artifacts: 'build/release/bin/*,build/dist/*.deb',
fingerprint: true
)
sh "cp build/dist/*.deb ${env.JENKINS_HOME}/artifacts"
build(
job: "/utils/apt",
wait: true,
propagate: true,
parameters: [[
$class: 'StringParameterValue',
name: 'filename',
value: "${debname}_${version}_amd64.deb"
]]
)
sh "docker tag monero:${version} monero:${docker_tag}"
sh "docker tag monero:${version} git.sudo.is/ben/monero:${docker_tag}"
sh "docker tag monero:${version} git.sudo.is/ben/monero:${version}"
sh "docker push git.sudo.is/ben/monero:${version}"
sh "docker push git.sudo.is/ben/monero:${docker_tag}"
}
}
cleanup {
script {
sh "rm build/dist/*.deb || true"
sh "rm build/release/bin/* || true"
sh "docker container rm monero_builder || true"
}
}
}
}