Build: Archive build/generated folder in per-patch

Files in build/generated are needed for reference.
Archive this folder in per-patch jobs.

Signed-off-by: Xinyu Zhang <xinyu.zhang@arm.com>
Change-Id: I5e060b0d5975558ced4340cd443c9f1501157993
diff --git a/jenkins/build-config.jpl b/jenkins/build-config.jpl
index 665f939..f5dc3e9 100644
--- a/jenkins/build-config.jpl
+++ b/jenkins/build-config.jpl
@@ -14,6 +14,12 @@
   nodeLabel = "docker-amd64-tf-m-bionic"
 }
 
+@NonCPS
+def getUpstreamJob() {
+  def cause = manager.build.getAction(hudson.model.CauseAction.class).getCauses()
+  return cause
+}
+
 node(nodeLabel) {
   stage("Init") {
     cleanWs()
@@ -100,6 +106,10 @@
     stage("Post") {
       archiveArtifacts 'trusted-firmware-m/build/bin/**'
       archiveArtifacts 'trusted-firmware-m/build/install/interface/**'
+      def upstreamProject = getUpstreamJob()[0].upstreamProject
+      if (upstreamProject == "tf-m-build-and-test") {
+        archiveArtifacts 'trusted-firmware-m/build/generated/**'
+      }
       if (env.SQUAD_CONFIGURATIONS != ""){
         //Creating a folder to store memory footprint artifacts and launching the memory footprint script.
         sh "mkdir tf-m-ci-scripts/Memory_footprint/"