<?xml version='1.1' encoding='UTF-8'?>
<flow-definition plugin="workflow-job">
  <actions/>
  <description></description>
  <keepDependencies>false</keepDependencies>
  <properties>
    <hudson.plugins.buildblocker.BuildBlockerProperty plugin="build-blocker-plugin">
      <useBuildBlocker>true</useBuildBlocker>
      <blockLevel>GLOBAL</blockLevel>
      <scanQueueFor>DISABLED</scanQueueFor>
      <blockingJobs>@REPO_NAME@-pipeline</blockingJobs>
    </hudson.plugins.buildblocker.BuildBlockerProperty>
    <jenkins.model.BuildDiscarderProperty>
      <strategy class="hudson.tasks.LogRotator">
        <daysToKeep>30</daysToKeep>
        <numToKeep>20</numToKeep>
        <artifactDaysToKeep>-1</artifactDaysToKeep>
        <artifactNumToKeep>-1</artifactNumToKeep>
      </strategy>
    </jenkins.model.BuildDiscarderProperty>
    <com.sonyericsson.jenkins.plugins.bfa.model.ScannerJobProperty plugin="build-failure-analyzer">
      <doNotScan>false</doNotScan>
    </com.sonyericsson.jenkins.plugins.bfa.model.ScannerJobProperty>
    <com.coravy.hudson.plugins.github.GithubProjectProperty plugin="github">
      <projectUrl>https://github.com/theorchard/@REPO_NAME@/</projectUrl>
      <displayName></displayName>
    </com.coravy.hudson.plugins.github.GithubProjectProperty>
    <hudson.plugins.throttleconcurrents.ThrottleJobProperty plugin="throttle-concurrents">
      <maxConcurrentPerNode>0</maxConcurrentPerNode>
      <maxConcurrentTotal>0</maxConcurrentTotal>
      <categories class="java.util.concurrent.CopyOnWriteArrayList"/>
      <throttleEnabled>false</throttleEnabled>
      <throttleOption>project</throttleOption>
      <limitOneJobWithMatchingParams>false</limitOneJobWithMatchingParams>
      <paramsToUseForLimit></paramsToUseForLimit>
    </hudson.plugins.throttleconcurrents.ThrottleJobProperty>
    <org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
      <triggers>
        <com.github.kostyasha.github.integration.branch.GitHubBranchTrigger plugin="github-pullrequest">
          <spec></spec>
          <triggerMode>HEAVY_HOOKS</triggerMode>
          <cancelQueued>false</cancelQueued>
          <abortRunning>false</abortRunning>
          <skipFirstRun>false</skipFirstRun>
          <repoProviders>
            <com.github.kostyasha.github.integration.generic.repoprovider.GitHubPluginRepoProvider>
              <cacheConnection>true</cacheConnection>
              <manageHooks>true</manageHooks>
              <repoPermission>ADMIN</repoPermission>
            </com.github.kostyasha.github.integration.generic.repoprovider.GitHubPluginRepoProvider>
          </repoProviders>
          <errorsAction>
            <description>GitHub Branches Trigger Errors</description>
            <errors class="java.util.Collections$SynchronizedSet" serialization="custom">
              <java.util.Collections_-SynchronizedCollection>
                <default>
                  <c class="set"/>
                  <mutex class="java.util.Collections$SynchronizedSet" reference="../../.."/>
                </default>
              </java.util.Collections_-SynchronizedCollection>
            </errors>
          </errorsAction>
          <preStatus>false</preStatus>
        </com.github.kostyasha.github.integration.branch.GitHubBranchTrigger>
        <com.cloudbees.jenkins.GitHubPushTrigger plugin="github">
          <spec></spec>
        </com.cloudbees.jenkins.GitHubPushTrigger>
      </triggers>
    </org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
  </properties>
  <definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="workflow-cps">
    <script>node() {
    stage(&apos;Get Git Commit&apos;) {
        checkout([$class: &apos;GitSCM&apos;, branches: [[name: &apos;*/master&apos;]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: &apos;@GITHUB_CREDENTIAL_ID@&apos;, url: &apos;git@github.com:theorchard/@REPO_NAME@.git&apos;]]])
        GIT_COMMIT = sh(returnStdout: true, script: &apos;git rev-parse HEAD&apos;).trim()
        MASTER_COMMIT = sh(returnStdout: true, script: &apos;git rev-parse HEAD~1&apos;).trim()
        DIFF_FILES = sh(returnStdout: true, script: &quot;git diff --name-only --diff-filter=d ${MASTER_COMMIT} ${GIT_COMMIT}&quot;)
        script{
            LAMBDA_DIRS = []
            for (item in DIFF_FILES.split(&apos;\n&apos;)){
                if (item.contains(&apos;/&apos;)){
                    lambda_dir = item.split(&apos;/&apos;)[1]
                    if (!LAMBDA_DIRS.contains(lambda_dir)){
                        LAMBDA_DIRS.add(lambda_dir)
                    }
                }
            }
        }
    }
    stage(&apos;Trigger Lambda Pipelines&apos;) {
        script{
            // pipelines are non-blocking by default, can spawn multiple
            for (LAMBDA_DIR in LAMBDA_DIRS){
                echo &quot;git commit: ${GIT_COMMIT}&quot;
                echo &quot;lambda dir: ${LAMBDA_DIR}&quot;
                PIPELINE_NAME = &apos;@REPO_NAME@-pipeline&apos;
                if (dir(&quot;lambda/${LAMBDA_DIR}&quot;) {!fileExists(&quot;Dockerfile&quot;)}) {
                    PIPELINE_NAME += &apos;-old&apos;
                }
                echo &quot;pipeline name: ${PIPELINE_NAME}&quot;
                build job: PIPELINE_NAME, parameters: [string(name: &apos;GIT_COMMIT&apos;, value: GIT_COMMIT), string(name: &apos;LAMBDA_DIR&apos;, value: LAMBDA_DIR)], wait: false
            }
        }
    }
}
</script>
    <sandbox>true</sandbox>
  </definition>
  <triggers/>
  <disabled>false</disabled>
</flow-definition>
