blob: 605f28598e12be46ec535c145d7349eff5a9f9af [file] [log] [blame]
Jeremy Ronquillo9adc0a92020-01-29 10:49:45 -08001// 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
18pipeline {
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") {
Jeremy Ronquillo3ca065c2020-04-24 10:40:54 -070040 when {
41 expression {return params.ghprbPullId != ""}
42 }
Jeremy Ronquillo9adc0a92020-01-29 10:49:45 -080043 steps {
44 checkout([
45 $class: 'GitSCM',
Jeremy Ronquillof86b8362020-03-17 13:20:10 -070046 userRemoteConfigs: [[ url: "https://github.com/${params.ghprbGhRepository}", refspec: "pull/${params.ghprbPullId}/head" ]],
47 extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: "${params.project}"]],
Jeremy Ronquillo9adc0a92020-01-29 10:49:45 -080048 ],
49 )
50 }
51 }
52
Jeremy Ronquillo3ca065c2020-04-24 10:40:54 -070053 stage ("Checkout Repo (manual)") {
54 when {
55 expression {return params.ghprbPullId == ""}
56 }
57 steps {
58 checkout([
59 $class: 'GitSCM',
60 userRemoteConfigs: [[ url: "https://github.com/${params.ghprbGhRepository}" ]],
61 extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: "${params.project}"]],
62 ],
63 )
64 }
65 }
66
Jeremy Ronquillo9adc0a92020-01-29 10:49:45 -080067 stage("Run REUSE Linter"){
68 steps {
Jeremy Ronquillo3ca065c2020-04-24 10:40:54 -070069 sh """
Jeremy Ronquillo9adc0a92020-01-29 10:49:45 -080070 #!/usr/bin/env bash
71
Jeremy Ronquillo3ca065c2020-04-24 10:40:54 -070072 cd ${params.project}
Jeremy Ronquilloa4e0cc22020-04-24 21:57:58 -070073 if [ ! -z ${params.ghprbPullId} ]
Jeremy Ronquillo3ca065c2020-04-24 10:40:54 -070074 then
75 git checkout FETCH_HEAD
76 else
77 git checkout ${params.branch}
78 fi
Jeremy Ronquilloae95dac2020-02-11 15:17:28 -080079 git show
Jeremy Ronquillo1ec06c42020-04-23 10:24:05 -070080 reuse lint
Jeremy Ronquillo3ca065c2020-04-24 10:40:54 -070081 """
Jeremy Ronquillo9adc0a92020-01-29 10:49:45 -080082 }
83 }
84 }
85}