blob: 24c6cab7566e6edb4bb76a2008bbf2dbcda02dc5 [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-fossa-scan.groovy
16// checks an omec-project repo against fossa in a docker container
17
18pipeline {
19
20 agent {
21 docker {
22 image "fossa-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 Ronquillof86b8362020-03-17 13:20:10 -070043 userRemoteConfigs: [[ url: "https://github.com/${params.ghprbGhRepository}", refspec: "pull/${params.ghprbPullId}/head" ]],
44 extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: "${params.project}"]],
Jeremy Ronquillo9adc0a92020-01-29 10:49:45 -080045 ],
46 )
47 }
48 }
49
50 stage ("Perform License Scan") {
51 steps {
52 withCredentials([string(credentialsId: 'fossa-api-key', variable: 'FOSSA_API_KEY')]) {
53 sh """
54 #!/usr/bin/env bash
55
Jeremy Ronquillof86b8362020-03-17 13:20:10 -070056 cd ${params.project}
Jeremy Ronquillo9adc0a92020-01-29 10:49:45 -080057 git checkout FETCH_HEAD
Jeremy Ronquilloae95dac2020-02-11 15:17:28 -080058 git show
59
Jeremy Ronquillo9adc0a92020-01-29 10:49:45 -080060 echo "Testing project: ${params.project}"
61
62 echo "Run 'fossa init'"
63 fossa init --no-ansi --verbose
64
65 echo "Contents of .fossa.yml generated by 'fossa init':"
66 cat .fossa.yml
67
68 echo "Run 'fossa analyze'"
69 fossa analyze --no-ansi --verbose
70
71 echo "Get FOSSA test results with 'fossa test'"
72 fossa test --no-ansi --verbose
Jeremy Ronquillo77dc6c72020-03-02 15:59:04 -080073
74 echo "Display list of licenses detected by FOSSA using 'fossa report licenses'"
75 fossa report licenses
Jeremy Ronquillo9adc0a92020-01-29 10:49:45 -080076 """
77
78 }
79 }
80 }
81 }
82}