pipeline {
  agent { label 'linux-python-git' }
  options {
    skipDefaultCheckout(true)
    disableConcurrentBuilds()
    timeout(time: 10, unit: 'MINUTES')
  }
  triggers { pollSCM('H/5 * * * *') }
  stages {
    stage('Checkout') {
      steps {
        deleteDir()
        checkout scm
        sh 'git rev-parse HEAD'
      }
    }
    stage('Test') {
      steps { sh 'python3 -m unittest discover -v' }
    }
    stage('Package') {
      steps {
        sh 'mkdir -p dist && git archive --format=zip --output=dist/app.zip HEAD'
        archiveArtifacts artifacts: 'dist/app.zip', fingerprint: true
      }
    }
  }
}
