Add manual run to FOSSA and REUSE license scans for OMEC repos.

Change-Id: Ia31ff00228af7937de97ea86d0c714fc59297e43
diff --git a/jjb/omec-ci.yaml b/jjb/omec-ci.yaml
index d7a46bc..0a75009 100644
--- a/jjb/omec-ci.yaml
+++ b/jjb/omec-ci.yaml
@@ -347,6 +347,16 @@
 
     parameters:
       - string:
+          name: ghprbPullId
+          default: '$ghprbPullId'
+          description: 'Pull request number to fetch changes from. Leave blank to run manually.'
+
+      - string:
+          name: branch
+          default: '$ghprbTargetBranch'
+          description: 'Branch to run. Only used when manually run.'
+
+      - string:
           name: buildNode
           default: '{build-node}'
           description: 'Name of the Jenkins executor node to run the job on'
@@ -356,6 +366,11 @@
           default: '{project}'
           description: 'Name of the project'
 
+      - string:
+          name: ghprbGhRepository
+          default: '{github-organization}/{project}'
+          description: 'Repository of the project.'
+
     triggers:
       - cord-infra-github-pr-trigger:
           github_pr_org_list: '{obj:github_pr_org_list}'
@@ -391,6 +406,16 @@
 
     parameters:
       - string:
+          name: ghprbPullId
+          default: '$ghprbPullId'
+          description: 'Pull request number to fetch changes from. Leave blank to run manually.'
+
+      - string:
+          name: branch
+          default: '$ghprbTargetBranch'
+          description: 'Branch to run. Only used when manually run.'
+
+      - string:
           name: buildNode
           default: '{build-node}'
           description: 'Name of the Jenkins executor node to run the job on'
@@ -400,6 +425,11 @@
           default: '{project}'
           description: 'Name of the project'
 
+      - string:
+          name: ghprbGhRepository
+          default: '{github-organization}/{project}'
+          description: 'Repository of the project.'
+
     triggers:
       - cord-infra-github-pr-trigger:
           github_pr_org_list: '{obj:github_pr_org_list}'
diff --git a/jjb/pipeline/omec-fossa-scan.groovy b/jjb/pipeline/omec-fossa-scan.groovy
index 24c6cab..a6c2169 100644
--- a/jjb/pipeline/omec-fossa-scan.groovy
+++ b/jjb/pipeline/omec-fossa-scan.groovy
@@ -37,6 +37,9 @@
         }
 
         stage ("Checkout Pull Request") {
+            when {
+                expression {return params.ghprbPullId != ""}
+            }
             steps {
                 checkout([
                     $class: 'GitSCM',
@@ -47,6 +50,20 @@
             }
         }
 
+        stage ("Checkout Repo (manual)") {
+            when {
+                expression {return params.ghprbPullId == ""}
+            }
+            steps {
+                checkout([
+                    $class: 'GitSCM',
+                    userRemoteConfigs: [[ url: "https://github.com/${params.ghprbGhRepository}" ]],
+                    extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: "${params.project}"]],
+                    ],
+                )
+            }
+        }
+
         stage ("Perform License Scan") {
             steps {
                 withCredentials([string(credentialsId: 'fossa-api-key', variable: 'FOSSA_API_KEY')]) {
@@ -54,7 +71,12 @@
                         #!/usr/bin/env bash
 
                         cd ${params.project}
-                        git checkout FETCH_HEAD
+                        if [ ! -Z ${params.ghprbPullId} ]
+                        then
+                          git checkout FETCH_HEAD
+                        else
+                          git checkout ${params.branch}
+                        fi
                         git show
 
                         echo "Testing project: ${params.project}"
diff --git a/jjb/pipeline/omec-reuse-scan.groovy b/jjb/pipeline/omec-reuse-scan.groovy
index 55aa0c4..9db0c9c 100644
--- a/jjb/pipeline/omec-reuse-scan.groovy
+++ b/jjb/pipeline/omec-reuse-scan.groovy
@@ -37,6 +37,9 @@
         }
 
         stage ("Checkout Pull Request") {
+            when {
+                expression {return params.ghprbPullId != ""}
+            }
             steps {
                 checkout([
                     $class: 'GitSCM',
@@ -47,16 +50,35 @@
             }
         }
 
+        stage ("Checkout Repo (manual)") {
+            when {
+                expression {return params.ghprbPullId == ""}
+            }
+            steps {
+                checkout([
+                    $class: 'GitSCM',
+                    userRemoteConfigs: [[ url: "https://github.com/${params.ghprbGhRepository}" ]],
+                    extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: "${params.project}"]],
+                    ],
+                )
+            }
+        }
+
         stage("Run REUSE Linter"){
             steps {
-                sh  '''
+                sh  """
                     #!/usr/bin/env bash
 
-                    cd $project
-                    git checkout FETCH_HEAD
+                    cd ${params.project}
+                    if [ ! -Z ${params.ghprbPullId} ]
+                    then
+                      git checkout FETCH_HEAD
+                    else
+                      git checkout ${params.branch}
+                    fi
                     git show
                     reuse lint
-                    '''
+                    """
             }
         }
     }