def gitCommitSha
pipeline {
    agent none
    stages {
        stage('Initialize') {
            agent any
            steps {
                script {
                    echo "Aggregator is running for branch: [${env.BRANCH_NAME}]"
                    def scmVars = checkout scm
                    gitCommitSha = scmVars.GIT_COMMIT
                    echo "Successfully found commit SHA: [${gitCommitSha}]"
                }
            }
        }

        stage('Trigger Build & Test Matrix') {
            parallel {
                stage('Trigger Linux JDK 17') {
                    steps {
                        build job: 'installer/jobs/linux-jdk17',
                              wait: true,
                              propagate: true,
                              parameters: [
                                string(name: 'GIT_COMMIT_SHA', value: gitCommitSha)
                              ]
                    }
                }

                stage('Trigger Linux JDK 21') {
                    steps {
                        build job: 'installer/jobs/linux-jdk21',
                              wait: true,
                              propagate: true,
                              parameters: [
                                string(name: 'GIT_COMMIT_SHA', value: gitCommitSha)
                              ]
                    }
                }

                stage('Trigger Windows JDK 17') {
                    steps {
                        build job: 'installer/jobs/windows-jdk17',
                              wait: true,
                              propagate: true,
                              parameters: [
                                string(name: 'GIT_COMMIT_SHA', value: gitCommitSha)
                              ]
                    }
                }

                stage('Trigger Windows JDK 21') {
                    steps {
                        build job: 'installer/jobs/windows-jdk21',
                              wait: true,
                              propagate: true,
                              parameters: [
                                string(name: 'GIT_COMMIT_SHA', value: gitCommitSha)
                              ]
                    }
                }
            }
        }
    }
}