hydrogen-docker/Jenkinsfile

93 lines
2.8 KiB
Groovy

pipeline {
agent any
triggers {
parameterizedCron('''@daily''')
}
options {
timestamps()
ansiColor("xterm")
disableConcurrentBuilds()
skipDefaultCheckout()
}
stages {
stage('checkout') {
steps{
checkout scm
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/heads/master']],
extensions: [[
$class: 'RelativeTargetDirectory',
relativeTargetDir: 'hydrogen-web'
]],
doGenerateSubmoduleConfigurations: false,
// extensions: [[$class: 'CloneOption',
// depth: 1, noTags: false, shallow: true]],
userRemoteConfigs: [[
url: 'https://git.sudo.is/matrix/hydrogen-web.git'
]],
])
}
}
stage ('build') {
steps {
sh "docker build --pull -t hydrogen-builder ."
}
}
stage('deb') {
steps {
script {
sh "docker container create --name hydrogen_builder hydrogen-builder"
sh "docker container cp hydrogen_builder:/deb/target/ ."
def debfile = readFile("target/version.txt").trim()
currentBuild.description = "${debfile}"
}
}
}
}
post {
success {
script {
// def debfile = readFile("target/version.txt").trim()
def debfile = currentBuild.description
archiveArtifacts(
artifacts: 'target/' + debfile,
fingerprint: true
)
// def timer = currentBuild.getBuildCauses()[0]["shortDescription"].matches("Started by timer")
// if (!fileExists("${env.JENKINS_HOME}/artifacts/${debfile}")) {
// }
sh "cp target/${debfile} ${env.JENKINS_HOME}/artifacts"
build(
job: "/utils/apt",
wait: true,
propagate: true,
parameters: [[
$class: 'StringParameterValue',
name: 'filename',
value: "${debfile}"
]])
}
}
cleanup {
cleanWs(
deleteDirs: true,
//patterns: [[pattern: 'hydrogen-web', type: 'EXCLUDE']],
disableDeferredWipeout: true,
notFailBuild: true
)
script {
sh "docker container rm hydrogen_builder || true"
sh "ls -lah"
}
}
}
}