Skip to content

Instantly share code, notes, and snippets.

@jbfavre
Created July 20, 2016 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jbfavre/5ebb74cad4c2d3f6344834c46d42c976 to your computer and use it in GitHub Desktop.
Save jbfavre/5ebb74cad4c2d3f6344834c46d42c976 to your computer and use it in GitHub Desktop.
Jenkins Debian Glue - Jenkins Pipeline
// Checkout package git repository
stage('Checkout GIT repository')
node('master'){
deleteDir()
checkout changelog: false,
poll: false,
scm: [$class: 'GitSCM',
branches: [[name: "${branch}"]],
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'RelativeTargetDirectory', relativeTargetDir: 'source']
],
submoduleCfg: [],
userRemoteConfigs: [[
credentialsId: '6e8f0868-0181-4e3b-9bc5-0e05c823de1c',
url: 'git@ci.jbfav.re:python-protobix.git'
]]
]
}
// Build source package
// Requires master node because of git checkout
stage('Build source package')
node('master'){
withEnv([
"release=${release}",
"branch=${branch}",
"tag=${tag}",
"distribution=${distribution}",
"WORKSPACE=${env.WORKSPACE}"
]) {
sh '/usr/bin/generate-git-snapshot'
}
// Need to stash source artifacts to be able to transfert them on slaves if needed
stash name: 'source',
includes: '*.gz,*.bz2,*.xz,*.deb,*.dsc,*.changes, lintian.txt',
useDefaultExcludes: false
}
// Build binary packages
// Can be done on slave if no dependencies from APT repository
// Must be done on master if apt repository needed (PHP extensions for example)
stage('Build binary packages')
node('slave'){
deleteDir() // Workspace cleaning
unstash 'source' // Get source artifacts back
withEnv([
"release=${release}",
"branch=${branch}",
"tag=${tag}",
"distribution=${distribution}",
"BUILD_ONLY=true",
"SUDO_CMD=sudo",
]) {
sh '/usr/bin/build-and-provide-package'
}
// Need to stash binaries artifacts to be able to transfert them on master if needed
stash name: 'binaries',
includes: '*.gz,*.bz2,*.xz,*.deb,*.dsc,*.changes, lintian.txt',
useDefaultExcludes: false
}
// Add source & binaries packages to APT repository
// Must be done on master
stage('Add packages to APT repository')
node('master'){
deleteDir() // Workspace cleaning
unstash 'binaries' // get back binaries artifacts
withEnv([
"release=${release}",
"branch=${branch}",
"tag=${tag}",
"distribution=${distribution}",
"PROVIDE_ONLY=true",
"REPO_CODENAME=${distribution}",
"BASE_PATH=."
]) {
sh '/usr/bin/build-and-provide-package'
}
}
stage('Archive artifacts')
node('master'){
unstash 'binaries' // Needed to be able to archive artifacts
archive '*.gz,*.bz2,*.xz,*.deb,*.dsc,*.changes, lintian.txt'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment