Jeremy Ronquillo | 9adc0a9 | 2020-01-29 10:49:45 -0800 | [diff] [blame] | 1 | // Copyright 2020-present Open Networking Foundation |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | // omec-reuse-scan.groovy |
| 16 | // checks an omec-project repo against reuse in a docker container |
| 17 | |
| 18 | pipeline { |
| 19 | |
| 20 | agent { |
| 21 | docker { |
| 22 | image "reuse-verify:latest" |
| 23 | label "${params.buildNode}" |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | options { |
| 28 | timeout(15) |
| 29 | } |
| 30 | |
| 31 | stages { |
| 32 | |
| 33 | stage ("Clean Workspace") { |
| 34 | steps { |
| 35 | sh 'rm -rf *' |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | stage ("Checkout Pull Request") { |
| 40 | steps { |
| 41 | checkout([ |
| 42 | $class: 'GitSCM', |
Jeremy Ronquillo | f86b836 | 2020-03-17 13:20:10 -0700 | [diff] [blame] | 43 | userRemoteConfigs: [[ url: "https://github.com/${params.ghprbGhRepository}", refspec: "pull/${params.ghprbPullId}/head" ]], |
| 44 | extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: "${params.project}"]], |
Jeremy Ronquillo | 9adc0a9 | 2020-01-29 10:49:45 -0800 | [diff] [blame] | 45 | ], |
| 46 | ) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | stage("Run REUSE Linter"){ |
| 51 | steps { |
Jeremy Ronquillo | 8c3333c | 2020-03-27 12:59:48 -0700 | [diff] [blame] | 52 | sh ''' |
Jeremy Ronquillo | 9adc0a9 | 2020-01-29 10:49:45 -0800 | [diff] [blame] | 53 | #!/usr/bin/env bash |
| 54 | |
Jeremy Ronquillo | 8c3333c | 2020-03-27 12:59:48 -0700 | [diff] [blame] | 55 | cd $project |
Jeremy Ronquillo | 9adc0a9 | 2020-01-29 10:49:45 -0800 | [diff] [blame] | 56 | git checkout FETCH_HEAD |
Jeremy Ronquillo | ae95dac | 2020-02-11 15:17:28 -0800 | [diff] [blame] | 57 | git show |
| 58 | |
Jeremy Ronquillo | f86b836 | 2020-03-17 13:20:10 -0700 | [diff] [blame] | 59 | mkdir ../jenkins-license-scan |
Jeremy Ronquillo | 8c3333c | 2020-03-27 12:59:48 -0700 | [diff] [blame] | 60 | modifiedFiles=$(git diff-tree --no-commit-id --name-only -r HEAD) |
| 61 | if [ -n "$modifiedFiles" ] |
| 62 | then |
| 63 | cp --parents "$modifiedFiles" ../jenkins-license-scan |
| 64 | cd ../jenkins-license-scan |
Jeremy Ronquillo | f86b836 | 2020-03-17 13:20:10 -0700 | [diff] [blame] | 65 | |
Jeremy Ronquillo | 8c3333c | 2020-03-27 12:59:48 -0700 | [diff] [blame] | 66 | reuse download --all |
| 67 | reuse lint |
| 68 | else |
| 69 | echo "There were no files to check. Skipping REUSE scan." |
| 70 | fi |
| 71 | ''' |
Jeremy Ronquillo | 9adc0a9 | 2020-01-29 10:49:45 -0800 | [diff] [blame] | 72 | } |
| 73 | } |
| 74 | } |
| 75 | } |