Zack Williams | 3bf60d5 | 2019-06-07 12:56:10 -0700 | [diff] [blame^] | 1 | // 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-single.groovy |
| 14 | // checks a single repo against synopsys |
| 15 | |
| 16 | pipeline { |
| 17 | |
| 18 | /* no label, executor is determined by JJB */ |
| 19 | agent { |
| 20 | label "${params.executorNode}" |
| 21 | } |
| 22 | |
| 23 | options { |
| 24 | timeout(30) |
| 25 | } |
| 26 | |
| 27 | stages { |
| 28 | |
| 29 | stage ("Clean workspace") { |
| 30 | steps { |
| 31 | sh 'rm -rf *' |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | stage('checkout') { |
| 36 | steps { |
| 37 | checkout([ |
| 38 | $class: 'GitSCM', |
| 39 | userRemoteConfigs: [[ |
| 40 | url: "${params.gitUrl}", |
| 41 | name: "${params.gitRef}", |
| 42 | ]], |
| 43 | extensions: [ |
| 44 | [$class: 'WipeWorkspace'], |
| 45 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "${params.projectName}"], |
| 46 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 47 | ], |
| 48 | ]) |
| 49 | script { |
| 50 | git_tag_or_branch = sh(script:"cd $projectName; if [[ \$(git tag -l --points-at HEAD) ]]; then git tag -l --points-at HEAD; else ${branchName}; fi", returnStdout: true).trim() |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | stage ("Synopsys Detect") { |
| 56 | steps { |
| 57 | sh "echo Running Synopsys Detect on: ${params.projectName}" |
| 58 | synopsys_detect("--detect.source.path=${params.projectName} --detect.project.name=${blackduck_project}_${params.projectName} --detect.project.version.name=$git_tag_or_branch --detect.blackduck.signature.scanner.snippet.mode=true --detect.tools=ALL --detect.cleanup=false") |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | stage ("Save logs") { |
| 63 | steps { |
| 64 | sh returnStdout: true, script: """ |
| 65 | echo COPYING LOGS |
| 66 | mkdir -p bd_logs |
| 67 | cp -r /home/jenkins/blackduck/runs/* bd_logs |
| 68 | ls -l bd_logs/*/* |
| 69 | """ |
| 70 | archiveArtifacts artifacts:'bd_logs/**/*.*' |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | } |