Add pr jobs

Signed-off-by: Arthur She <arthur.she@linaro.org>
Change-Id: I7e8d57933c05a7393c8fb68551b551786769e589
diff --git a/mbed-tls-pr-head.yaml b/mbed-tls-pr-head.yaml
new file mode 100644
index 0000000..fa822ac
--- /dev/null
+++ b/mbed-tls-pr-head.yaml
@@ -0,0 +1,50 @@
+- job:
+    name: mbed-tls-pr-head
+    description: 'Job for testing mbed tls PR heads'
+    project-type: multibranch
+    disabled: true
+    prune-dead-branches: true
+    days-to-keep: 60
+    num-to-keep: 1000
+    script-path: tests/.jenkins/Jenkinsfile
+    properties:
+      - raw:
+          xml: |
+            <org.jenkinsci.plugins.workflow.libs.FolderLibraries plugin="workflow-cps-global-lib@2.9">
+              <libraries>
+                <org.jenkinsci.plugins.workflow.libs.LibraryConfiguration>
+                  <name>mbedtls-test</name>
+                  <retriever class="org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever">
+                    <scm class="org.jenkinsci.plugins.github_branch_source.GitHubSCMSource" plugin="github-branch-source@2.9.1">
+                      <repoOwner>Mbed-TLS</repoOwner>
+                      <repository>mbedtls-test</repository>
+                      <repositoryUrl>https://github.com/Mbed-TLS/mbedtls-test.git</repositoryUrl>
+                    </scm>
+                  </retriever>
+                  <defaultVersion>master</defaultVersion>
+                  <implicit>true</implicit>
+                  <allowVersionOverride>true</allowVersionOverride>
+                  <includeInChangesets>true</includeInChangesets>
+                </org.jenkinsci.plugins.workflow.libs.LibraryConfiguration>
+              </libraries>
+            </org.jenkinsci.plugins.workflow.libs.FolderLibraries>
+    scm:
+    - github:
+        api-uri: https://api.github.com
+        credentials-id: mbedtls-github-token
+        repo-owner: Mbed-TLS
+        repo: mbedtls
+        repository-url: https://github.com/Mbed-TLS/mbedtls.git
+        branch-discovery: no-pr
+        discover-pr-forks-strategy: both
+        discover-pr-forks-trust: permission
+        discover-pr-origin: both
+        head-filter-regex: '(?!^PR-(1824)-(merge|head)$)(PR-\d+-head)'
+        property-strategies:
+          all-branches:
+          - pipeline-branch-durability-override: performance-optimized
+        submodule:
+          disable: false
+          recursive: true
+          tracking: false
+          parent-credentials: false
diff --git a/mbed-tls-restricted-pr.yaml b/mbed-tls-restricted-pr.yaml
new file mode 100644
index 0000000..e0cc7d9
--- /dev/null
+++ b/mbed-tls-restricted-pr.yaml
@@ -0,0 +1,51 @@
+- job:
+    name: mbed-tls-restricted-pr
+    description: 'mbedtls restricted PR job'
+    project-type: multibranch
+    prune-dead-branches: true
+    days-to-keep: -1
+    num-to-keep: -1
+    script-path: tests/.jenkins/Jenkinsfile
+    properties:
+      - raw:
+          xml: |
+            <org.jenkinsci.plugins.workflow.libs.FolderLibraries plugin="workflow-cps-global-lib@2.9">
+              <libraries>
+                <org.jenkinsci.plugins.workflow.libs.LibraryConfiguration>
+                  <name>mbedtls-test</name>
+                  <retriever class="org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever">
+                    <scm class="org.jenkinsci.plugins.github_branch_source.GitHubSCMSource" plugin="github-branch-source@2.9.1">
+                      <repoOwner>Mbed-TLS</repoOwner>
+                      <repository>mbedtls-test</repository>
+                      <repositoryUrl>https://github.com/Mbed-TLS/mbedtls-test.git</repositoryUrl>
+                    </scm>
+                  </retriever>
+                  <defaultVersion>master</defaultVersion>
+                  <implicit>true</implicit>
+                  <allowVersionOverride>true</allowVersionOverride>
+                  <includeInChangesets>true</includeInChangesets>
+                </org.jenkinsci.plugins.workflow.libs.LibraryConfiguration>
+              </libraries>
+            </org.jenkinsci.plugins.workflow.libs.FolderLibraries>
+    scm:
+    - github:
+        api-uri: https://api.github.com
+        credentials-id: mbedtls-github-token
+        repo-owner: Mbed-TLS
+        repo: mbedtls-restricted
+        repository-url: ssh://git@github.com/Mbed-TLS/mbedtls-restricted.git
+        branch-discovery: no-pr
+        discover-pr-forks-strategy: both
+        discover-pr-forks-trust: permission
+        discover-pr-origin: both
+        head-filter-regex: '(?!^PR-(758|759|850|906|916|919)-(merge|head)$)(PR-\d+-(merge|head))'
+        property-strategies:
+          all-branches:
+          - pipeline-branch-durability-override: performance-optimized
+        submodule:
+          disable: false
+          recursive: true
+          tracking: false
+          parent-credentials: false
+        ssh-checkout:
+          credentials: mbedtls-github-ssh
diff --git a/mbedtls-gather-timestamps.yaml b/mbedtls-gather-timestamps.yaml
new file mode 100644
index 0000000..ffc31c5
--- /dev/null
+++ b/mbedtls-gather-timestamps.yaml
@@ -0,0 +1,24 @@
+- job:
+    concurrent: true
+    description: Mbed TLS job to gather timestamps from various jobs' runs
+    name: mbedtls-gather-timestamps
+    disabled: true
+    pipeline-scm:
+      lightweight-checkout: true
+      scm:
+      - git:
+          branches:
+          - master
+          url: https://github.com/Mbed-TLS/mbedtls-test.git
+      script-path: vars/mbedtls-gather-timestamps-Jenkinsfile
+    project-type: pipeline
+    properties:
+    - speed-durability:
+        hint: performance-optimized
+    - build-discarder:
+        artifact-days-to-keep: -1
+        artifact-num-to-keep: -1
+        days-to-keep: 120
+        num-to-keep: 120
+    triggers:
+    - timed: 0 8 * * *
diff --git a/mbedtls-pr-multibranch.yaml b/mbedtls-pr-multibranch.yaml
new file mode 100644
index 0000000..d87deb9
--- /dev/null
+++ b/mbedtls-pr-multibranch.yaml
@@ -0,0 +1,59 @@
+- job:
+    name: mbedtls-pr-multibranch
+    description: 'mbedtls PR job'
+    project-type: multibranch
+    prune-dead-branches: true
+    script-path: tests/.jenkins/Jenkinsfile
+    properties:
+      - raw:
+          xml: |
+            <org.jenkinsci.plugins.workflow.libs.FolderLibraries plugin="workflow-cps-global-lib@2.9">
+              <libraries>
+                <org.jenkinsci.plugins.workflow.libs.LibraryConfiguration>
+                  <name>mbedtls-test</name>
+                  <retriever class="org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever">
+                    <scm class="org.jenkinsci.plugins.github_branch_source.GitHubSCMSource" plugin="github-branch-source@2.9.1">
+                      <repoOwner>Mbed-TLS</repoOwner>
+                      <repository>mbedtls-test</repository>
+                      <repositoryUrl>https://github.com/Mbed-TLS/mbedtls-test.git</repositoryUrl>
+                      <traits>
+                        <org.jenkinsci.plugins.github__branch__source.BranchDiscoveryTrait>
+                          <strategyId>1</strategyId>
+                        </org.jenkinsci.plugins.github__branch__source.BranchDiscoveryTrait>
+                        <org.jenkinsci.plugins.github__branch__source.OriginPullRequestDiscoveryTrait>
+                          <strategyId>2</strategyId>
+                        </org.jenkinsci.plugins.github__branch__source.OriginPullRequestDiscoveryTrait>
+                        <org.jenkinsci.plugins.github__branch__source.ForkPullRequestDiscoveryTrait>
+                          <strategyId>2</strategyId>
+                          <trust class="org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustPermission"/>
+                        </org.jenkinsci.plugins.github__branch__source.ForkPullRequestDiscoveryTrait>
+                      </traits>
+                    </scm>
+                  </retriever>
+                  <defaultVersion>master</defaultVersion>
+                  <implicit>true</implicit>
+                  <allowVersionOverride>true</allowVersionOverride>
+                  <includeInChangesets>true</includeInChangesets>
+                </org.jenkinsci.plugins.workflow.libs.LibraryConfiguration>
+              </libraries>
+            </org.jenkinsci.plugins.workflow.libs.FolderLibraries>
+    scm:
+    - github:
+        api-uri: https://api.github.com
+        credentials-id: mbedtls-github-token
+        repo-owner: Mbed-TLS
+        repo: mbedtls
+        repository-url: https://github.com/Mbed-TLS/mbedtls.git
+        branch-discovery: no-pr
+        discover-pr-origin: both
+        discover-pr-forks-strategy: both
+        discover-pr-forks-trust: permission
+        head-filter-regex: '(?!^PR-(1824)-(merge|head)$)(PR-\d+-(merge|head))'
+        property-strategies:
+            all-branches:
+                - suppress-scm-triggering: true
+        submodule:
+          disable: false
+          recursive: true
+          tracking: false
+          parent-credentials: false
diff --git a/mbedtls-repo-scan-scheduler.yaml b/mbedtls-repo-scan-scheduler.yaml
new file mode 100644
index 0000000..39994dc
--- /dev/null
+++ b/mbedtls-repo-scan-scheduler.yaml
@@ -0,0 +1,23 @@
+- job:
+    concurrent: true
+    description: |-
+      This job exists to schedule the nightly repository scans.
+      There appears to be an issue with automatically scanning if there are more than one multibranch pipelines on the same repo.
+    disabled: false
+    dsl: |-
+      build job: "mbed-tls-pr-merge", wait: false, propagate: false
+      build job: "mbed-tls-pr-head", wait: false, propagate: false
+      build job: "mbed-tls-restricted-pr", wait: false, propagate: false
+    name: mbedtls-repo-scan-scheduler
+    project-type: pipeline
+    sandbox: true
+    triggers:
+    - timed: 0 20 * * *
+    properties:
+    - speed-durability:
+        hint: performance-optimized
+    - build-blocker:
+        block-level: GLOBAL
+        blocking-jobs: []
+        queue-scanning: DISABLED
+        use-build-blocker: false