@Library('ftewa-jenkins-library@main') _

@NonCPS
def getPipelineJobNames() {
    Hudson.instance.getAllItems(org.jenkinsci.plugins.workflow.job.WorkflowJob)*.fullName 
}

@NonCPS
def triggerJobs() {
  def jobs = getPipelineJobNames();
    
    for (job in jobs)
    {
      echo "Trigger ${job}"
      if (job.contains("Integration"))
      {
        build job: job, 
          parameters: [
            string(name: 'REPO_NAME', value: "cmake"),
            string(name: 'TAG', value: "main")
          ],
          wait: false

      }
    }
}

pipeline {
  agent {
     kubernetes {
       //workspaceVolume: dynamicPVC(accessModes: 'ReadWriteOnce', requestsSize: '20G', storageClassName: 'csi-rbd-sc')
       yaml libraryResource("files/pod-build.yml")
       defaultContainer 'clang-build'
     }
  } // agent
  options {
    // Only keep the 1 most recent builds
    buildDiscarder(logRotator(numToKeepStr: "1"))
  }


stages {

  stage("Build")
  {

    steps {
                echo "build"
                triggerJobs()
          }


    
    
    
  } // stage("Build")

  }
}
