pipeline {
    agent any
    
    stages {
        stage('Clone') {
            steps {
                git branch: 'main', url: 'https://git.siwatsystem.com/ise-senior-iot/iot-firmware.git'
            }
        }
        stage('Build') {
            steps {
                sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio'
                sh 'python3 gen_release.py'
            }
        }
        stage('Publish') {
            steps {
                sh 'mkdir -p artifacts'
                sh 'cp -r release/ artifacts/'
                archiveArtifacts artifacts: 'artifacts/**/*', fingerprint: true
            }
        }
    }
}
