// Separate artifact-only demo job. Keep existing delivery/recovery jobs intact.
pipeline {
    agent { label 'delivery-trusted' }
    options {
        disableConcurrentBuilds()
        timeout(time: 45, unit: 'MINUTES')
        buildDiscarder(logRotator(numToKeepStr: '10'))
    }
    environment { DELIVERY_VERSION = "1.0.${BUILD_NUMBER}" }
    stages {
        stage('Verify reviewed source and frozen baseline') {
            steps {
                sh 'python3 demo/ci/reset-output.py'
                sh 'git merge-base --is-ancestor HEAD origin/main'
                sh 'python3 demo/ci/verify-snapshot.py --require-tracked'
            }
        }
        stage('Build application and test provider') {
            steps { sh 'sh demo/ci/run-cloud.sh native' }
        }
        stage('Compile LaTeX reports') {
            steps { sh 'sh demo/ci/run-cloud.sh report' }
        }
        stage('Extract source architecture') {
            steps { sh 'sh demo/ci/run-cloud.sh architecture' }
        }
        stage('Package versioned artifact') {
            steps { sh 'sh demo/ci/run-cloud.sh package' }
        }
    }
    post {
        always {
            archiveArtifacts artifacts: 'build/demo/artifacts/*,build/demo/reports/*',
                             allowEmptyArchive: true, fingerprint: true
            junit testResults: 'build/demo/reports/tests.xml', allowEmptyResults: true
        }
    }
}
