blob: f454d29147d8cb94ad7e9992d9e19d1ca7584527 [file] [log] [blame]
Zack Williamsc1d6a5e2019-05-06 16:35:58 -07001// Licensed under the Apache License, Version 2.0 (the "License");
2// you may not use this file except in compliance with the License.
3// You may obtain a copy of the License at
4//
5// http://www.apache.org/licenses/LICENSE-2.0
6//
7// Unless required by applicable law or agreed to in writing, software
8// distributed under the License is distributed on an "AS IS" BASIS,
9// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10// See the License for the specific language governing permissions and
11// limitations under the License.
12
13// synopsys-check.groovy
14
15pipeline {
16
17 /* no label, executor is determined by JJB */
18 agent {
19 label "${params.executorNode}"
20 }
21
22 options {
23 timeout(30)
24 }
25
26 stages {
27
28 stage ("Clean workspace") {
29 steps {
30 sh 'rm -rf *'
31 }
32 }
33
34 stage ("Get repo list") {
35 steps {
36 script {
37 def repos = sh(
38 returnStdout: true,
39 script: """
40 #!/usr/bin/env bash
41 set -eu -o pipefail
42
43 if [ -z "${github_organization}" ]
44 then
45 # no github org set, assume gerrit server
46 curl "${git_server_url}/projects/?pp=0" | python -c 'import json,sys; ij=sys.stdin.readlines(); obj=json.loads(ij[1]); print(",".join(obj.keys()))'
47 else
48 # github org set, assume github organization
49 curl -sS "https://api.github.com/orgs/${github_organization}/repos" | python -c 'import json,sys;obj=json.load(sys.stdin); print ",".join(map(lambda item: item["name"], obj))'
50 fi
51 """
52 ).split(",")
53 }
54 }
55 }
56
57 stage ("Checkout repos") {
58 steps {
59 script {
60 repos.each { gitRepo ->
61 sh "echo Checking out: ${gitRepo}"
62 checkout(
63 [
64 $class: 'GitSCM',
65 userRemoteConfigs: [[
66 url: "${params.git_server_url}/${gitRepo}/",
67 name: "${branch}",
68 ]],
69 extensions: [
70 [$class: 'RelativeTargetDirectory', relativeTargetDir: "${gitRepo}"],
71 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
72 ],
73 ])
74 }
75 }
76 }
77 }
78
79 stage ("Synopsys Detect") {
80 steps {
81 script {
82 repos.each { gitRepo ->
83 sh "echo Running Synopsys Detect on: ${gitRepo}"
84 synopsys_detect("--detect.source.path=${gitRepo} --detect.project.name=${blackduck_project} --detect.project.version.name=${branch} --detect.blackduck.signature.scanner.snippet.mode=true --detect.tools=ALL --detect.cleanup=false")
85 }
86 }
87 }
88 }
89
90 stage ("Save logs") {
91 steps {
92 sh returnStdout: true, script: """
93 echo COPYING LOGS
94 mkdir -p bd_logs
95 cp -r /home/jenkins/blackduck/runs/* bd_logs
96 ls -l bd_logs/*/*
97 """
98 archiveArtifacts artifacts:'bd_logs/**/*.*'
99 }
100 }
101 }
102}