Skip to content

Commit

Permalink
feat(detectExecuteScan) Added npm install step for detectExectueScan (#…
Browse files Browse the repository at this point in the history
…4949)

* Added npm install step for detectExectueScan
  • Loading branch information
andrew-kireev authored Jun 6, 2024
1 parent df1db9e commit e2a5b09
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cmd/detectExecuteScan.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
piperhttp "github.com/SAP/jenkins-library/pkg/http"
"github.com/SAP/jenkins-library/pkg/log"
"github.com/SAP/jenkins-library/pkg/maven"
"github.com/SAP/jenkins-library/pkg/npm"
"github.com/SAP/jenkins-library/pkg/orchestrator"
"github.com/SAP/jenkins-library/pkg/piperutils"
"github.com/SAP/jenkins-library/pkg/reporting"
Expand Down Expand Up @@ -213,6 +214,22 @@ func runDetect(ctx context.Context, config detectExecuteScanOptions, utils detec
}
}

// Install NPM dependencies
if config.InstallNPM {
log.Entry().Debugf("running npm install")
npmExecutor := npm.NewExecutor(npm.ExecutorOptions{DefaultNpmRegistry: config.DefaultNpmRegistry})

buildDescriptorList := config.BuildDescriptorList
if len(buildDescriptorList) == 0 {
buildDescriptorList = []string{"package.json"}
}

err := npmExecutor.InstallAllDependencies(buildDescriptorList)
if err != nil {
return err
}
}

// for MTA
if config.BuildMTA {
log.Entry().Infof("running MTA Build")
Expand Down
33 changes: 33 additions & 0 deletions cmd/detectExecuteScan_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions resources/metadata/detectExecuteScan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,32 @@ spec:
- STEPS
- STAGES
- PARAMETERS
- name: installNPM
type: bool
default: false
description:
"Experiment parameter for downloading npm dependencies"
scope:
- STEPS
- STAGES
- PARAMETERS
- name: defaultNpmRegistry
type: string
description: "URL of the npm registry to use. Defaults to https://registry.npmjs.org/"
scope:
- PARAMETERS
- GENERAL
- STAGES
- STEPS
aliases:
- name: npm/defaultNpmRegistry
- name: buildDescriptorList
type: "[]string"
description: List of build descriptors and therefore modules for execution of the npm scripts. The elements have to be paths to the build descriptors.
scope:
- PARAMETERS
- STAGES
- STEPS
- name: enableDiagnostics
type: bool
default: false
Expand Down

0 comments on commit e2a5b09

Please sign in to comment.