1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
Commit Graph

297 Commits

Author SHA1 Message Date
Daniel Kurzynski
5749b47c75
Fix containers map and add test (#1769) 2020-07-07 12:07:44 +02:00
Florian Wilhelm
b5dbd0dafc
Cf create services in multiclouddeploy step (#1736) 2020-07-01 17:28:50 +02:00
lydiazcheng
59f3cddd43
TMS: extend upload mta ext descriptor to node (#1635)
* add APIs for getNodes, getExtDescriptor, putExtDescriptor and uploadExtDescriptor
* add new params and extend the logic to enable upload or update extension descriptor to node
* extends unit tests


Co-authored-by: Zihe Cheng <zihe.cheng@sap.com>
Co-authored-by: Marcus Holl <marcus.holl@sap.com>
2020-06-22 11:34:10 +02:00
Alexander Link
a864cf0f60
Fix docker.includes in WhitesourceConfigurationHelper (#1666)
* Fix docker.includes in WhitesourceConfigurationHelper

Not sure, but it seems the [`docker.includes` parameter](https://whitesource.atlassian.net/wiki/spaces/WD/pages/804814917/Unified+Agent+Configuration+File+and+Parameters#UnifiedAgentConfigurationFileandParameters-DockerImages) needs to be a regex.

Our pipeline is failing with:
```
10:22:33  [ERROR] [2020-06-15 08:22:33,740 +0000] - Resolve DockerEntity Exception Dangling meta character '*' near index 0
10:22:33  *.tar
10:22:33  ^
10:22:33  [DEBUG] [2020-06-15 08:22:33,743 +0000] - Resolve DockerEntity Exception {}
10:22:33  java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0
10:22:33  *.tar
10:22:33  ^
10:22:33  	at java.base/java.util.regex.Pattern.error(Unknown Source)
10:22:33  	at java.base/java.util.regex.Pattern.sequence(Unknown Source)
10:22:33  	at java.base/java.util.regex.Pattern.expr(Unknown Source)
10:22:33  	at java.base/java.util.regex.Pattern.compile(Unknown Source)
10:22:33  	at java.base/java.util.regex.Pattern.<init>(Unknown Source)
10:22:33  	at java.base/java.util.regex.Pattern.compile(Unknown Source)
10:22:33  	at org.whitesource.utils.WssStringUtils.isMatchingPattern(WssStringUtils.java:49)
10:22:33  	at org.whitesource.agent.dependency.resolver.docker.DockerResolver.filterTarImagesToScan(DockerResolver.java:296)
10:22:33  	at org.whitesource.agent.dependency.resolver.docker.DockerResolver.resolveDockerEntities(DockerResolver.java:186)
10:22:33  	at org.whitesource.fs.scanOrigins.DockerEntityScanOrigin.scan(DockerEntityScanOrigin.java:66)
10:22:33  	at org.whitesource.fs.scanOrigins.ScanOrigin.runOriginScan(ScanOrigin.java:36)
10:22:33  	at org.whitesource.fs.FileSystemAgent.createProjects(FileSystemAgent.java:132)
10:22:33  	at org.whitesource.fs.Main.scanAndSend(Main.java:157)
10:22:33  	at org.whitesource.fs.Main.main(Main.java:102)
10:22:33  [WARN] [2020-06-15 08:22:33,744 +0000] - Resolve DockerEntity Exception Dangling meta character '*' near index 0
10:22:33  *.tar
10:22:33  ^
```

* Switch docker.includes to slashy string

* Fix docker includes pattern in tests

Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
Co-authored-by: D070410 <srinikitha.kondreddy@sap.com>
2020-06-15 17:02:28 +02:00
sudeepsukumar
702664645c
feat(newman): fetch xsuaa credentials in newman execution (#1325)
* fetch xsuaa credentials in newman execution

* refactor CfUtils and moving to integration package

* removing CfUtils from old package com.sap.piper

* avoid config.verbose as "null"

* variable renamed for consistent naming

* handling NPE and other comments incorp

* added test cases

Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>
2020-06-12 10:04:03 +02:00
Daniel Kurzynski
d9a8537eb5
Revert to again use curl to download binary (#1637)
Revert "Remove curl for unstashing binary (#1580)"
This reverts commit 8b296f74

Improve error message

Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>
2020-06-10 10:11:20 +02:00
Marcus Holl
f071b4490d
Fix: yaml util handling for boolean with value false (#1629)
* Provide test for yamlUtils substitution with boolean value false

* Fix: handle booleans with value 'false' in yaml substitution

* Improve variable naming
2020-06-04 06:03:12 +02:00
Oliver Nocon
5e27d26a7c
whitesourceExecuteScan: add Docker image scanning (#1556)
* whitesourceExecuteScan: add Docker image scanning

* add test

* Update whitesourceExecuteScan.groovy

* Update WhitesourceConfigurationHelper.groovy
2020-05-27 16:27:36 +02:00
Daniel Kurzynski
8b296f7420
Remove curl for unstashing binary (#1580) 2020-05-27 13:30:04 +02:00
Marcus Holl
1836bb728b
Emit piper version to log (#1583)
* introduce variable for piper bin

* log the version of the piper bin

* don't fail with generic message from script execution (sh)
2020-05-26 09:38:47 +02:00
Stephan Aßmus
7d3f201609
Ignore invalid entries in custom defaults (#1558)
Extend tests, ignore invalid custom defaults entries
2020-05-18 10:59:02 +02:00
Christopher Fenner
27c6320474
feat(sonar): write flag for sonar execution to influx (#1534)
* write flag for sonar execution to influx

* add missing step metadata file

* first attempt to read influx from disk

* add missing import

* correct glob pattern

* use file path

* correct type names

* cleanup

* fix code climate issue

* fix typo

Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com>

* add test case

Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com>
2020-05-14 13:46:40 +02:00
Florian Wilhelm
eaf5479e9c
Fix maven parameter handling (#1493)
Avoid maven error `Unknown lifecycle phase \"-\"` when the value of a define contains `-`.

Don't split and trim maven arguments. Expect they come in as a list, keep them as list.

This is a breaking change compared to the old Groovy implementation which relied on using a shell for calling maven.

As an example, consider this diff:

```diff
-        goals: 'org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate',
-        defines: "-Dexpression=$pomPathExpression -DforceStdout -q",
+        goals: ['org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate'],
+        defines: ["-Dexpression=$pomPathExpression", "-DforceStdout", "-q"],
```
2020-05-06 17:43:32 +02:00
Daniel Kurzynski
974327d16e
Use mavenExecute from go (#1388)
Also establish mavenExecute() via new JenkinsMavenExecuteRule in Groovy Unit Tests.

Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com>
Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>
2020-04-24 10:41:49 +02:00
artembannikov
8206fb9716
TMS: Print response content for status codes 3xx in addition to 4xx and 5xx (#1441)
* Extend JenkinsLoggingRule and TransportManagementServiceTest

* Print response content for status codes >= 300, also test that it's not
revealed in the case of unexpected status codes between 200 and 300
(both not included) for authentication

Co-authored-by: Marcus Holl <marcus.holl@sap.com>
2020-04-23 09:46:25 +02:00
Daniel Kurzynski
1c247de9d0
Add option to always run stages in a pod (#1414) 2020-04-17 10:31:04 +02:00
artembannikov
4553c8f278
TMS: explicitly check in tests that there is no token in the logs (#1370)
* Check in the tests explicitly that token is not present in logs

* Address feedback

Co-authored-by: Marcus Holl <marcus.holl@sap.com>
2020-04-07 15:42:38 +02:00
artembannikov
20a8d3b656
Exchange dummy(.)com in tests with a more secure URL (#1371)
Co-authored-by: Marcus Holl <marcus.holl@sap.com>
2020-04-07 14:52:27 +02:00
artembannikov
26feb014df
TMS: implement response processing based on its HTTP response code for authentication and uploadFileToNode (#1335)
* Expose error message if status is not 200, extend junit tests

* Address feedback

Co-authored-by: Marcus Holl <marcus.holl@sap.com>
2020-04-06 11:29:18 +02:00
Marcus Holl
4b93dc5db7
Provide response from tms file upload also in case of rc outside 2xx (#1297)
* Provide response from tms file upload also in case of return codes outside 2xx

* Update src/com/sap/piper/integration/TransportManagementService.groovy

Co-Authored-By: Oliver Feldmann <oliver.feldmann@sap.com>

* Update src/com/sap/piper/integration/TransportManagementService.groovy

Co-Authored-By: Oliver Feldmann <oliver.feldmann@sap.com>

* consider re-running in verbose mode only if we are not in verbose mode

* Add missing script reference when calling error

* avoid curl --fail in order to get also a response in case of 4xx 5xx

* add missing write-out

* --output instead of -o

* fix syntax errors

* fix codeclimat issue

* fix unit tests /1

* Adjust unit tests

* More unit tests

* Use other texts in verbose mode and non verbose mode in case of a failure

in order to avoid issue with hanging log messages surviving a test case (... should not be the case).

For the non verbose mode we check the http response code since there is not message we can check.

* Now with the full comment explaining the 418

* Provide different responses for verbose and non-verbose mode

in order to distinguish the cases

Co-authored-by: Oliver Feldmann <oliver.feldmann@sap.com>
2020-04-06 10:13:10 +02:00
Florian Geckeler
5e35869f7c
Use stable version for setting maven version (#1332) 2020-04-03 18:16:58 +02:00
Marcus Holl
67e984addc
Dont expose token during tms auth request (#1294)
* [refactoring] return the http response from sendApiRequest

* Don't expose token after authentification request

* Update src/com/sap/piper/integration/TransportManagementService.groovy

Co-Authored-By: arktiker <45875324+arktiker@users.noreply.github.com>

* provide return keyword - it is better to understand ...

* fix assert log message

Co-authored-by: Oliver Feldmann <oliver.feldmann@sap.com>
Co-authored-by: arktiker <45875324+arktiker@users.noreply.github.com>
2020-04-01 08:55:17 +02:00
Srinikitha Kondreddy
38237eb97b
Update mta yaml file to support cloud MBT mtar deploy to neo. (#1198)
* Update schema and hcp deployer version in mta.yaml file

* Add name parameter in mta yaml file

* Rename template_mta.yml to template_mta.yaml

* Fix indentation

Co-authored-by: Oliver Feldmann <oliver.feldmann@sap.com>
Co-authored-by: Marcus Holl <marcus.holl@sap.com>
2020-02-20 14:57:50 +01:00
Oliver Nocon
321f8fbbc1
More resilient handling of download errors for piper bin (#1147)
* fix #1114
* Update test/groovy/com/sap/piper/PiperGoUtilsTest.groovy
* add log output
2020-02-12 09:02:39 +01:00
Stephan Aßmus
c628d208c7
Implement archiving the debug report as step (#1152)
* Implement archiving the debug report as step
2020-02-07 16:30:08 +01:00
redehnroV
2ebf2010b7
Protecode as GoLang (#1119)
* Protecode as go implementation

Co-authored-by: Sven Merk <33895725+nevskrem@users.noreply.github.com>
Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
2020-02-06 16:16:34 +01:00
Stephan Aßmus
1d9ecdb999 Added EnvironmentUtils needed by DebugReport
This should have been added along with DebugReport. For context:
EnvironmentUtils used to be a class alongside DebugReport and thus
there was no 'import' directive. Working with Jenkins DSL stuff
has numbed my ability to pay attention to the IDE indicating errors.
2020-02-03 17:07:56 +01:00
Sven Merk
36423eb78d
Avoid potential collisions among steps (#1141)
* Avoid potential collisions amongst steps

* Improve code, move to JenkinsUtils

* Improve code

* Improve tests

* Fix test

* Add scope on golang side
2020-02-03 15:25:49 +01:00
Stephan Aßmus
8e953715a0 DebugReport: Log failure to retrieve Jenkins plugins 2020-02-03 12:37:20 +01:00
Stephan Aßmus
6e551dfc79 Add DebugReport facility
The DebugReport is a global instance where steps can store information relevant for diagnosing failed pipelines. In the SDK Pipeline, this is used to generate a debug report within the postActionArchiveDebugLog step. The reason for adding this to Piper is to feed information about extended or overwritten stages in piperStageWrapper into the DebugReport, as was done before in the SDK Pipeline's equivalent runAsStage step.
2020-02-03 12:37:20 +01:00
Florian Geckeler
b509e14afd
Use maven evaluate for mavenArtifactVersioning
* add evaluateFromMavenPom to piper Utils
* adapt mavenExecute to accept `returnStdout` as parameter. If configured mavenExecute will return the stdout for further processing
* adapt tests of mavenExecute and mavenArtifactVersioning as well as add another exception to CommonStepsTest because mavenExecute will return a String if configured
2020-01-23 09:31:01 +01:00
Sven Merk
544765b97b Test platform interoperability 2019-12-16 10:03:34 +01:00
Sven Merk
d4bd52f14b Fix test 2019-12-16 09:55:07 +01:00
Marcus Holl
d0d4b37b24 Revert "ConfigurationLoader, ConfigurationHelper working without script reference"
This reverts commit 9962060254.
2019-11-26 10:51:32 +01:00
Oliver Nocon
e671094308
Use piper binary for githubPublishRelease (#990)
* Use piper binary for githubPublishRelease
2019-11-21 16:34:22 +01:00
Florian Wilhelm
5b58ce830f
Clarify precedence in MapUtils#merge() (#983) 2019-11-14 14:33:23 +01:00
Marcus Holl
7ed89ea223 Don't use deprecated methods with CPE null 2019-11-12 15:57:16 +01:00
Marcus Holl
3d94511bdd Merge remote-tracking branch 'github/master' into HEAD 2019-11-12 15:37:26 +01:00
Oliver Nocon
da0935c0e5
Patch Urls (#929)
* Patch Urls
* fix test
2019-11-11 17:40:23 +01:00
Oliver Nocon
de31cde9b8
Add PiperGoUtils for downloading piper binary (#928)
* Add PiperGoUtils for downloading piper binary

PiperGoUtils provide the link between a Jenkins library step and the library step execution running in a go binary.

It makes sure that an adequate binary is available.

* fix CodeClimate finding

* Remove Delimiter and add download resilience.
2019-11-06 11:28:10 +01:00
TheFonz2017
41dcebb3a5 Variable Substitution in YAML Files (#852)
* Changes:
- New YamlSubstituteVariables step to substitute variables in YAML files with values from another YAML
- New Tests, that check the different substitution patterns.
- Added test resources, including various manifest and variables files.
- Improved usage of JenkinsLoggingRule
- Improved JenkinsReadYamlRule to properly reflect the mocked library's behaviour.
- Added a new JenkinsWriteYamlRule.

* Changes:
- added a Logger that checks a config.verbose flag before it logs debug messages.
- changed error handling to rethrow Yaml parsing exception in case of wrongly-formatted Yaml files.
- changed JenkinsWriteYamlRule to capture Yaml file details of every invocation of writeYaml. This allows sanity checks at end of tests, even if there were multiple invocations.
- adjusted tests.

* Changes:
- Removed javadoc-code blocks from API documentation since they are not supported.
- Removed skipDeletion boolean.
- Added a new deleteFile script which deletes a file if present.
- Added a new JenkinsDeleteFileRule to mock deleteFile script and optionally skip deletion for tests.
- Adjusted yamlSubstituteVariables script.
- Adjusted tests to include new JenkinsDeleteFileRule.
- Changed code that deletes an already existing output file to produce better logs.

* Changes:
- Turned yamlSubstituteVariables into a script that works purely based on Yaml data (not files).
- Added a new cfManifestSubstituteVariables that uses yamlSubstituteVariables under the hood but works based on files.
- Adjusted tests, and added new ones.

* Adjusted documentation and a few log statements.

* Changed documentation to no longer include javadoc code statements.

* Made mocking of deletion of a file a default. Adjusted tests.

* Changed signature of yamlSubstituteVariables' call method to return void.

* Changes:
- Fixed naming issues in deleteFile.
- Renamed Logger to DebugHelper.
- Fixed some documentation.

* Changed implementation of deleteFile not to use java.io.File - which is evil when using it for file operations.

* PROPERLY Changed implementation of deleteFile not to use java.io.File - which is evil when using it for file operations.

* Changes:
- Added tests for deleteFile script
- Changed JenkinsFileExistsRule to also keep track of which files have been queried for existence.

* Changes:
- Removed java.io.File usage from cfManifestSubstituteVariables and using fileExists instead now.
- Adjusted tests.

* Wrapped file path inside ticks to allow spaces in file path when calling deleteFile.

* Removed null checks of mandatory parameters, and resorted to ConfigurationHelper.withMandatoryProperty

* Fixed a NullPointer due to weird Jenkins / Groovy behaviour.

* Changes:
- Turned yamlSubstituteVariables step into a utils class.
- Added tests
- Adjusted cfManifestSubstituteVariables to use utils class instead of step.
- Adjusted tests
- Adjusted APIs of DebugHelper.

* Re-introduced log statement that shows what variables are being replaced and with what.

* Changing API of YamlUtils to take the script and config as input.

* Test

* Test

* Test

* Test

* Test

* Fixing issue.

* Fixing issue.

* Changes:
- Refactored DebugHelper and YamlUtils to make usage nicer and rely on dependency injection.
- Removed Field for DebugHelper and turned it into local variable.
- Adjusted classes using the above.
- Adjusted tests where necessary.

* Added link to CF standards to YamlUtils also.

* Add docu for step cfManifestSubstituteVariables.md

* Added documentation.

* Added missing script parameter to documentation. Some steps document it, some don't. Right now you need it, so we document it.

* Fixed some layouting and typos

* Beautified exception listing.

* Removed trailing whitespaces to make code climate checks pass.

* Trying to get documentation generated, with all the exceptions to markup one should not use.

* cosmetics.

* cosmetics, part 2

* Code climate changes...

* Inlined deleteFile step.

* Added two more tests to properly check file deletion and output handling.

* Changes:
- adjusted API to take a list of variables files, as does 'cf push --vars-file'
- adjusted API to allow for an optional list of variable key-value-maps as does 'cf push --vars'
- reproduced conflict resolution and overriding behavior of variables files and vars lists
- adjusted tests and documentation

* Added missing paramter to doc comment.

* Re-checked docs for missing paramters or params that have no counterpart in the method signature.

* Adjusted documentation.

* Removed absolute path usage from documentation.

* corrected documentation.

* Changed javadoc comment to plain comment.

* Turned all comments to plain comments.
2019-09-06 10:20:35 +02:00
Marcus Holl
9962060254 ConfigurationLoader, ConfigurationHelper working without script reference 2019-08-08 16:14:29 +02:00
Sven Merk
b1b480a7e1
Merge branch 'master' into whitesourceExecuteScan 2019-07-19 14:28:26 +02:00
tobiaslendle
cb245b1ce2 TMS integration (#782) 2019-07-18 15:06:11 +02:00
Andre Pany
0e990446fc whitesourceExecuteScan: Add scanType dub 2019-07-11 06:17:30 +02:00
andre2007
44f745d327 Rename dlang to dub (#762) 2019-07-03 11:27:07 +02:00
Oliver Nocon
9e539e68ee
Piper pipeline - enhance stages (#755)
* fill PRVoting stage with content
* add prVoting stage incl. tests
* add Build stage incl. Tests
* add docs pages
* add additional unit test stage
* add acceptance stage and additional documentation ...
* add release stage content
* add promote stage
* add Security stage, fix defaults for Promote stage
* fix issue in doc generation
2019-07-03 10:13:26 +02:00
Oliver Nocon
5bb6d59753
Add step buildExecute (#527)
This step should serve as generic entry point in pipelines for building artifacts.

Build principle: build once.

Purpose of the step:
- build using a defined build technology
- store build result for future use in testing etc.
2019-07-02 13:00:36 +02:00
Marcus Holl
ea5a3ed5ce Merge remote-tracking branch 'github/master' into HEAD 2019-06-25 08:49:30 +02:00
Oliver Nocon
79894bb36f
Fix docker versioning with registry port (#686)
Fix issue when retrieving version via tag in `FROM` section.
We also need to consider that the registry may contain a port.

* Update DockerArtifactVersioning.groovy
* add error message for missing image tag in FROM line
2019-06-19 13:00:56 +02:00