diff --git a/.Jenkinsfile b/.Jenkinsfile index 1c79152..cdf052a 100644 --- a/.Jenkinsfile +++ b/.Jenkinsfile @@ -1,21 +1,45 @@ pipeline { - agent { label 'docker' } + agent { label 'gbp' } + options { + // This is required to clean up before build + skipDefaultCheckout(true) + } stages { - stage('Build Debian package') { - agent { - docker { - image 'evolix/gbp:latest' - args '-v /tmp:/tmp' - } + stage("Env Variables") { + steps { + sh "printenv | sort" } + } + + stage('Build Debian package') { when { - branch 'debian' + branch 'wip-debian' } steps { + // Clean before build + cleanWs() script { - sh 'mk-build-deps --install --remove debian/control' - sh 'git clean --force' - sh 'gbp buildpackage' + // Explicitly checkout from SCM after clean up + def scmVars = checkout([ + $class: 'GitSCM', + branches: [[name: '*/wip-debian']], + doGenerateSubmoduleConfigurations: false, + extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'source']], + submoduleCfg: [], + userRemoteConfigs: [[url: 'https://gitea.evolix.org/evolix/evobackup.git']] + ]) + echo "scmVars.GIT_COMMIT" + env.GIT_COMMIT = scmVars.GIT_COMMIT + sh "echo Building ${env.JOB_NAME}..." + sh 'printenv | sort' + sh '/usr/bin/generate-git-snapshot' + sh '/usr/bin/build-and-provide-package' + /* Lintian */ + sh 'mkdir -p report' + /* For the source package */ + sh '/usr/bin/lintian-junit-report *.dsc > report/lintian.xml' + /* For the binary package */ + sh '/usr/bin/lintian-junit-report *.changes >> report/lintian.xml' } } } @@ -34,4 +58,16 @@ pipeline { } } } + post { + // Clean after build + always { + archiveArtifacts artifacts: '*.gz,*.bz2,*.xz,*.deb,*.dsc,*.changes,*.buildinfo,lintian.txt' + cleanWs(cleanWhenNotBuilt: false, + deleteDirs: true, + disableDeferredWipeout: true, + notFailBuild: true, + patterns: [[pattern: '.gitignore', type: 'INCLUDE'], + [pattern: '.propsfile', type: 'EXCLUDE']]) + } + } }