mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
Merge branch 'master' into CCFenner/INFLUX
This commit is contained in:
commit
19759bf754
@ -120,6 +120,10 @@ func triggerCheckout(repositoryName string, branchName string, checkoutConnectio
|
|||||||
return uriConnectionDetails, err
|
return uriConnectionDetails, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
// workaround until golang version 1.16 is used
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
log.Entry().WithField("StatusCode", resp.Status).WithField("ABAP Endpoint", checkoutConnectionDetails.URL).Info("Authentication on the ABAP system was successful")
|
log.Entry().WithField("StatusCode", resp.Status).WithField("ABAP Endpoint", checkoutConnectionDetails.URL).Info("Authentication on the ABAP system was successful")
|
||||||
uriConnectionDetails.XCsrfToken = resp.Header.Get("X-Csrf-Token")
|
uriConnectionDetails.XCsrfToken = resp.Header.Get("X-Csrf-Token")
|
||||||
checkoutConnectionDetails.XCsrfToken = uriConnectionDetails.XCsrfToken
|
checkoutConnectionDetails.XCsrfToken = uriConnectionDetails.XCsrfToken
|
||||||
|
@ -110,6 +110,10 @@ func triggerClone(repositoryName string, branchName string, cloneConnectionDetai
|
|||||||
return uriConnectionDetails, err
|
return uriConnectionDetails, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
// workaround until golang version 1.16 is used
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
log.Entry().WithField("StatusCode", resp.Status).WithField("ABAP Endpoint", cloneConnectionDetails.URL).Info("Authentication on the ABAP system successful")
|
log.Entry().WithField("StatusCode", resp.Status).WithField("ABAP Endpoint", cloneConnectionDetails.URL).Info("Authentication on the ABAP system successful")
|
||||||
uriConnectionDetails.XCsrfToken = resp.Header.Get("X-Csrf-Token")
|
uriConnectionDetails.XCsrfToken = resp.Header.Get("X-Csrf-Token")
|
||||||
cloneConnectionDetails.XCsrfToken = uriConnectionDetails.XCsrfToken
|
cloneConnectionDetails.XCsrfToken = uriConnectionDetails.XCsrfToken
|
||||||
|
@ -117,6 +117,10 @@ func triggerPull(repositoryName string, pullConnectionDetails abaputils.Connecti
|
|||||||
return uriConnectionDetails, err
|
return uriConnectionDetails, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
// workaround until golang version 1.16 is used
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
log.Entry().WithField("StatusCode", resp.Status).WithField("ABAP Endpoint", pullConnectionDetails.URL).Info("Authentication on the ABAP system successful")
|
log.Entry().WithField("StatusCode", resp.Status).WithField("ABAP Endpoint", pullConnectionDetails.URL).Info("Authentication on the ABAP system successful")
|
||||||
uriConnectionDetails.XCsrfToken = resp.Header.Get("X-Csrf-Token")
|
uriConnectionDetails.XCsrfToken = resp.Header.Get("X-Csrf-Token")
|
||||||
pullConnectionDetails.XCsrfToken = uriConnectionDetails.XCsrfToken
|
pullConnectionDetails.XCsrfToken = uriConnectionDetails.XCsrfToken
|
||||||
|
@ -235,6 +235,10 @@ func fetchXcsrfToken(requestType string, details abaputils.ConnectionDetailsHTTP
|
|||||||
return "", fmt.Errorf("Fetching Xcsrf-Token failed: %w", err)
|
return "", fmt.Errorf("Fetching Xcsrf-Token failed: %w", err)
|
||||||
}
|
}
|
||||||
defer req.Body.Close()
|
defer req.Body.Close()
|
||||||
|
|
||||||
|
// workaround until golang version 1.16 is used
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
token := req.Header.Get("X-Csrf-Token")
|
token := req.Header.Get("X-Csrf-Token")
|
||||||
return token, err
|
return token, err
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,9 @@ func detectExecuteScan(config detectExecuteScanOptions, telemetryData *telemetry
|
|||||||
log.ErrorCompliance.String(): {
|
log.ErrorCompliance.String(): {
|
||||||
"FAILURE_POLICY_VIOLATION - Detect found policy violations.",
|
"FAILURE_POLICY_VIOLATION - Detect found policy violations.",
|
||||||
},
|
},
|
||||||
|
log.ErrorConfiguration.String(): {
|
||||||
|
"FAILURE_CONFIGURATION - Detect was unable to start due to issues with it's configuration.",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// reroute command output to logging framework
|
// reroute command output to logging framework
|
||||||
|
@ -639,7 +639,7 @@ func executeNpmScanForModule(modulePath string, config *ScanOptions, scan *white
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := reinstallNodeModulesIfLsFails(modulePath, config, utils); err != nil {
|
if err := reinstallNodeModulesIfLsFails(config, utils); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -681,7 +681,7 @@ func getNpmProjectName(modulePath string, utils whitesourceUtils) (string, error
|
|||||||
// This hack/work-around that should be removed once scanning it consistently performed using the Unified Agent.
|
// This hack/work-around that should be removed once scanning it consistently performed using the Unified Agent.
|
||||||
// A possible reason for encountering "npm ls" errors in the first place is that a different node version
|
// A possible reason for encountering "npm ls" errors in the first place is that a different node version
|
||||||
// is used for whitesourceExecuteScan due to a different docker image being used compared to the build stage.
|
// is used for whitesourceExecuteScan due to a different docker image being used compared to the build stage.
|
||||||
func reinstallNodeModulesIfLsFails(modulePath string, config *ScanOptions, utils whitesourceUtils) error {
|
func reinstallNodeModulesIfLsFails(config *ScanOptions, utils whitesourceUtils) error {
|
||||||
// No need to have output from "npm ls" in the log
|
// No need to have output from "npm ls" in the log
|
||||||
utils.Stdout(ioutil.Discard)
|
utils.Stdout(ioutil.Discard)
|
||||||
defer utils.Stdout(log.Writer())
|
defer utils.Stdout(log.Writer())
|
||||||
@ -706,7 +706,8 @@ func reinstallNodeModulesIfLsFails(modulePath string, config *ScanOptions, utils
|
|||||||
return fmt.Errorf("failed to remove package-lock.json: %w", err)
|
return fmt.Errorf("failed to remove package-lock.json: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return utils.InstallAllNPMDependencies(config, []string{modulePath})
|
// Passing only "package.json", because we are already inside the module's directory.
|
||||||
|
return utils.InstallAllNPMDependencies(config, []string{"package.json"})
|
||||||
}
|
}
|
||||||
|
|
||||||
// executeYarnScan generates a configuration file whitesource.config.json with appropriate values from config,
|
// executeYarnScan generates a configuration file whitesource.config.json with appropriate values from config,
|
||||||
|
@ -131,6 +131,11 @@ type downloadedFile struct {
|
|||||||
filePath string
|
filePath string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type npmInstall struct {
|
||||||
|
currentDir string
|
||||||
|
packageJSON []string
|
||||||
|
}
|
||||||
|
|
||||||
type whitesourceUtilsMock struct {
|
type whitesourceUtilsMock struct {
|
||||||
*mock.FilesMock
|
*mock.FilesMock
|
||||||
*mock.ExecMockRunner
|
*mock.ExecMockRunner
|
||||||
@ -139,7 +144,7 @@ type whitesourceUtilsMock struct {
|
|||||||
usedBuildDescriptorFile string
|
usedBuildDescriptorFile string
|
||||||
usedOptions versioning.Options
|
usedOptions versioning.Options
|
||||||
downloadedFiles []downloadedFile
|
downloadedFiles []downloadedFile
|
||||||
npmInstalledModules []string
|
npmInstalledModules []npmInstall
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *whitesourceUtilsMock) DownloadFile(url, filename string, _ http.Header, _ []*http.Cookie) error {
|
func (w *whitesourceUtilsMock) DownloadFile(url, filename string, _ http.Header, _ []*http.Cookie) error {
|
||||||
@ -169,8 +174,11 @@ func (w *whitesourceUtilsMock) FindPackageJSONFiles(_ *ScanOptions) ([]string, e
|
|||||||
return matches, nil
|
return matches, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *whitesourceUtilsMock) InstallAllNPMDependencies(_ *ScanOptions, _ []string) error {
|
func (w *whitesourceUtilsMock) InstallAllNPMDependencies(_ *ScanOptions, packageJSONs []string) error {
|
||||||
w.npmInstalledModules = append(w.npmInstalledModules, w.CurrentDir)
|
w.npmInstalledModules = append(w.npmInstalledModules, npmInstall{
|
||||||
|
currentDir: w.CurrentDir,
|
||||||
|
packageJSON: packageJSONs,
|
||||||
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,7 +435,11 @@ func TestExecuteScanNPM(t *testing.T) {
|
|||||||
err := executeScan(&config, scan, utilsMock)
|
err := executeScan(&config, scan, utilsMock)
|
||||||
// assert
|
// assert
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, []string{"app", ""}, utilsMock.npmInstalledModules)
|
expectedNpmInstalls := []npmInstall{
|
||||||
|
{currentDir: "app", packageJSON: []string{"package.json"}},
|
||||||
|
{currentDir: "", packageJSON: []string{"package.json"}},
|
||||||
|
}
|
||||||
|
assert.Equal(t, expectedNpmInstalls, utilsMock.npmInstalledModules)
|
||||||
assert.True(t, utilsMock.HasRemovedFile("package-lock.json"))
|
assert.True(t, utilsMock.HasRemovedFile("package-lock.json"))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -124,8 +124,8 @@ func GetHTTPResponse(requestType string, connectionDetails ConnectionDetailsHTTP
|
|||||||
header["Accept"] = []string{"application/json"}
|
header["Accept"] = []string{"application/json"}
|
||||||
header["x-csrf-token"] = []string{connectionDetails.XCsrfToken}
|
header["x-csrf-token"] = []string{connectionDetails.XCsrfToken}
|
||||||
|
|
||||||
req, err := client.SendRequest(requestType, connectionDetails.URL, bytes.NewBuffer(body), header, nil)
|
httpResponse, err := client.SendRequest(requestType, connectionDetails.URL, bytes.NewBuffer(body), header, nil)
|
||||||
return req, err
|
return httpResponse, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleHTTPError handles ABAP error messages which can occur when using OData services
|
// HandleHTTPError handles ABAP error messages which can occur when using OData services
|
||||||
|
@ -246,7 +246,7 @@ func sendRequestInternal(sys *SystemInstance, method, url string, body io.Reader
|
|||||||
defer closer.Close()
|
defer closer.Close()
|
||||||
}
|
}
|
||||||
response, err := sys.client.SendRequest(method, fmt.Sprintf("%v/cxrestapi%v", sys.serverURL, url), requestBody, header, nil)
|
response, err := sys.client.SendRequest(method, fmt.Sprintf("%v/cxrestapi%v", sys.serverURL, url), requestBody, header, nil)
|
||||||
if err != nil && !piperutils.ContainsInt(acceptedErrorCodes, response.StatusCode) {
|
if err != nil && (response == nil || !piperutils.ContainsInt(acceptedErrorCodes, response.StatusCode)) {
|
||||||
sys.recordRequestDetailsInErrorCase(requestBodyCopy, response)
|
sys.recordRequestDetailsInErrorCase(requestBodyCopy, response)
|
||||||
sys.logger.Errorf("HTTP request failed with error: %s", err)
|
sys.logger.Errorf("HTTP request failed with error: %s", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -16,6 +16,7 @@ class PiperPipelineStageConfirmTest extends BasePiperTest {
|
|||||||
|
|
||||||
private Map timeoutSettings
|
private Map timeoutSettings
|
||||||
private Map inputSettings
|
private Map inputSettings
|
||||||
|
private milestoneCalled = false
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public RuleChain rules = Rules
|
public RuleChain rules = Rules
|
||||||
@ -37,6 +38,10 @@ class PiperPipelineStageConfirmTest extends BasePiperTest {
|
|||||||
inputSettings = m
|
inputSettings = m
|
||||||
return [reason: 'this is my test reason for failing step 1 and step 3', acknowledgement: true]
|
return [reason: 'this is my test reason for failing step 1 and step 3', acknowledgement: true]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
helper.registerAllowedMethod('milestone', [],{
|
||||||
|
milestoneCalled = true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -77,4 +82,13 @@ class PiperPipelineStageConfirmTest extends BasePiperTest {
|
|||||||
assertThat(jlr.log, containsString('this is my test reason'))
|
assertThat(jlr.log, containsString('this is my test reason'))
|
||||||
assertThat(jlr.log, containsString('Acknowledgement\n---------------\n☑ I acknowledge that for traceability purposes the approval reason is stored together with my user name / user id'))
|
assertThat(jlr.log, containsString('Acknowledgement\n---------------\n☑ I acknowledge that for traceability purposes the approval reason is stored together with my user name / user id'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void callsMilestone(){
|
||||||
|
jsr.step.piperPipelineStageConfirm(
|
||||||
|
script: nullScript
|
||||||
|
)
|
||||||
|
|
||||||
|
assertThat(milestoneCalled, is(true))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,8 @@ void call(Map parameters = [:]) {
|
|||||||
boolean approval = false
|
boolean approval = false
|
||||||
def userInput
|
def userInput
|
||||||
|
|
||||||
|
milestone()
|
||||||
|
|
||||||
timeout(
|
timeout(
|
||||||
unit: 'HOURS',
|
unit: 'HOURS',
|
||||||
time: config.manualConfirmationTimeout
|
time: config.manualConfirmationTimeout
|
||||||
|
Loading…
Reference in New Issue
Block a user