Skip to content

Commit e2a5b09

Browse files
feat(detectExecuteScan) Added npm install step for detectExectueScan (#4949)
* Added npm install step for detectExectueScan
1 parent df1db9e commit e2a5b09

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

cmd/detectExecuteScan.go

+17
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
piperhttp "github.com/SAP/jenkins-library/pkg/http"
2121
"github.com/SAP/jenkins-library/pkg/log"
2222
"github.com/SAP/jenkins-library/pkg/maven"
23+
"github.com/SAP/jenkins-library/pkg/npm"
2324
"github.com/SAP/jenkins-library/pkg/orchestrator"
2425
"github.com/SAP/jenkins-library/pkg/piperutils"
2526
"github.com/SAP/jenkins-library/pkg/reporting"
@@ -213,6 +214,22 @@ func runDetect(ctx context.Context, config detectExecuteScanOptions, utils detec
213214
}
214215
}
215216

217+
// Install NPM dependencies
218+
if config.InstallNPM {
219+
log.Entry().Debugf("running npm install")
220+
npmExecutor := npm.NewExecutor(npm.ExecutorOptions{DefaultNpmRegistry: config.DefaultNpmRegistry})
221+
222+
buildDescriptorList := config.BuildDescriptorList
223+
if len(buildDescriptorList) == 0 {
224+
buildDescriptorList = []string{"package.json"}
225+
}
226+
227+
err := npmExecutor.InstallAllDependencies(buildDescriptorList)
228+
if err != nil {
229+
return err
230+
}
231+
}
232+
216233
// for MTA
217234
if config.BuildMTA {
218235
log.Entry().Infof("running MTA Build")

cmd/detectExecuteScan_generated.go

+33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/metadata/detectExecuteScan.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,32 @@ spec:
266266
- STEPS
267267
- STAGES
268268
- PARAMETERS
269+
- name: installNPM
270+
type: bool
271+
default: false
272+
description:
273+
"Experiment parameter for downloading npm dependencies"
274+
scope:
275+
- STEPS
276+
- STAGES
277+
- PARAMETERS
278+
- name: defaultNpmRegistry
279+
type: string
280+
description: "URL of the npm registry to use. Defaults to https://registry.npmjs.org/"
281+
scope:
282+
- PARAMETERS
283+
- GENERAL
284+
- STAGES
285+
- STEPS
286+
aliases:
287+
- name: npm/defaultNpmRegistry
288+
- name: buildDescriptorList
289+
type: "[]string"
290+
description: List of build descriptors and therefore modules for execution of the npm scripts. The elements have to be paths to the build descriptors.
291+
scope:
292+
- PARAMETERS
293+
- STAGES
294+
- STEPS
269295
- name: enableDiagnostics
270296
type: bool
271297
default: false

0 commit comments

Comments
 (0)