From 5f4d4a87f7f367fc00cc3c420174b9fdc35f1d7c Mon Sep 17 00:00:00 2001 From: Dmytro Makovey Date: Wed, 11 Sep 2019 10:22:20 -0600 Subject: [PATCH] Add FOSSA checks to Jenkins CI Signed-off-by: Dmytro Makovey Signed-off-by: Tibor Vass --- Jenkinsfile | 29 +++++++++++++++++++++++++++++ Makefile.fossa | 18 ++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 Jenkinsfile create mode 100644 Makefile.fossa diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..77f8eba7 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,29 @@ + +@Library('jps') +_ + +pipeline { + agent { + node { + label 'ubuntu-1804-overlay2' + } + } + options { + disableConcurrentBuilds() + } + stages { + stage("FOSSA Analyze") { + steps { + + withCredentials([string(credentialsId: 'fossa-api-key', variable: 'FOSSA_API_KEY')]) { + withGithubStatus('FOSSA.scan') { + labelledShell returnStatus: false, returnStdout: true, label: "make fossa-analyze", + script:'make -f Makefile.fossa BRANCH_NAME=${BRANCH_NAME} fossa-analyze' + labelledShell returnStatus: false, returnStdout: true, label: "make fossa-test", + script: 'make -f Makefile.fossa BRANCH_NAME=${BRANCH_NAME} fossa-test' + } + } + } + } + } +} diff --git a/Makefile.fossa b/Makefile.fossa new file mode 100644 index 00000000..b89ec555 --- /dev/null +++ b/Makefile.fossa @@ -0,0 +1,18 @@ +REPO_PATH?=docker/buildx +BUILD_ANALYZER?=docker/fossa-analyzer +FOSSA_OPTS?=--option all-tags:true --option allow-unresolved:true --no-ansi + +fossa-analyze: + docker run -i --rm -e FOSSA_API_KEY=$(FOSSA_API_KEY) \ + -v $(CURDIR)/$*:/go/src/github.com/$(REPO_PATH) \ + -w /go/src/github.com/$(REPO_PATH) \ + -e GO111MODULE=on \ + $(BUILD_ANALYZER) analyze $(FOSSA_OPTS) --branch $(BRANCH_NAME) + +# This command is used to run the fossa test command +fossa-test: + docker run -i --rm -e FOSSA_API_KEY=$(FOSSA_API_KEY) \ + -v $(CURDIR)/$*:/go/src/github.com/$(REPO_PATH) \ + -w /go/src/github.com/$(REPO_PATH) \ + -e GO111MODULE=on \ + $(BUILD_ANALYZER) test --debug