1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00
Commit Graph

88 Commits

Author SHA1 Message Date
Roland Stengel
47d8d2c357
GPP Init Stage needs to consider mta yaml path (#3305)
mtaBuild - support config.source to yaml path
2021-12-14 14:43:02 +01:00
Srinikitha Kondreddy
efe3ab36f8
Support for secretfile type neo credential for deployment (#2537)
* Use Oauth bearer token credentials to deploy to neo

* Add test case

* Add test file

* Fix code climate issues

* Add code review changes
2021-01-26 09:29:44 +01:00
Srinikitha Kondreddy
e0c09992ce
Read properties from plain text (#2228)
* Read properties from plain text

* Adapt changes

* Support for properties provided as text (#2241)

* Fix indent and clean up exceptions

Co-authored-by: Marcus Holl <marcus.holl@sap.com>
2020-10-27 10:52:24 +01:00
Daniel Kurzynski
5749b47c75
Fix containers map and add test (#1769) 2020-07-07 12:07:44 +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
Daniel Kurzynski
8b296f7420
Remove curl for unstashing binary (#1580) 2020-05-27 13:30:04 +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
ea007c0d1f
Fix test by resetting application context after each test (#1352) 2020-04-01 11:51:20 +02:00
René Kschamer
d754a669b2
Add Docker deploy support to cloudFoundryDeploy (#977)
Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
Co-authored-by: Daniel Kurzynski <daniel.kurzynski@sap.com>
2020-02-25 10:20:15 +01:00
Stephan Aßmus
9658f3b480
writeFile() cannot be passed a Map (#1163)
* writeFile() cannot be passed a Map

I've changed the return type of DebugReport.generateReport() from
String to Map in order to get the generated file name as part of the
return value instead of getting it from a field of DebugReport. The
UnitTest checks whether writeFile() creates the debug_report file
successfully and whether it has the expected contents. The effect
of passing the Map instead of map.contents to writeFile() should
have been an unnecessary wrapping via Map.toString() as in the test,
but in the execution context of Jenkins, this throws an
IllegalArgumentException: Could not instantiate {... and then the
results of map.toString().

* Improve JenkinsWriteFileRule compatibility

Calling m.text.toString() is wrong, since the type stored at m.text
already needs to be a String (or GString). Expecting valid parameters
here makes sure problems are detected by tests already. (All tests
pass as before.)
2020-02-10 12:25:33 +01:00
Marcus Holl
7b95c04752
[refactor] CPE read/write from/to disk: remote repetitive coding (#1110)
Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
2020-01-28 13:22:37 +01:00
Oliver Nocon
a46b57e6b4
Persisted pipeline environment for golang library (#1091)
* Use commonPipelineEnvironment in go binary

* Update groovy part incl. tests

* Rework structure and naming

* Support influx resources in steps

* Update tests and some cleanups

* Add correct defer handling

* Address PR feedback

* Fix test

* Update resources.go

Co-authored-by: Sven Merk <33895725+nevskrem@users.noreply.github.com>
2020-01-15 12:16:25 +01:00
Marcus Holl
4bbfd78437 Revert "Back commonPipelineEnvironment step by shared class"
This reverts commit 149cd96dbf.
2019-11-26 10:43:59 +01:00
Marcus Holl
149cd96dbf Back commonPipelineEnvironment step by shared class 2019-09-27 13:54:58 +02:00
Marcus Holl
e418c15b6e
Revert "Back commonPipelineEnvironment step by shared class (#821)" (#885)
This reverts commit eb57c8df7b.
2019-09-26 14:18:18 +02:00
Marcus Holl
eb57c8df7b
Back commonPipelineEnvironment step by shared class (#821)
* Back commonPipelineEnvironment step by shared class

Each pipeline step comes with its own instance of a commonPipelineEnvironment.
Properties stored on one instance was not shared with the other instances.

Now we strip down the commonPipelineEnvironment step and forward basically
everything to a shared singleton instance.

With that approach all instances of commonPipelineEnvironment shares the
same data and can now be really used for information exchange between the steps.
Before that change only the commonPipelineEnvironment instance associated with
the pipeline script itself could be used for that purpose.

* Remove unneeded commented line
2019-09-26 12:23:36 +02:00
TheFonz2017
6dabdff8d5 Added (optional) Variable Substitution to CloudFoundryDeploy Step (#866) 2019-09-24 08:49:25 +02:00
Marcus Holl
e54f18e6bc
Introduce xsDeploy step (#749)
Introduce xs deploy
2019-09-11 13:42:38 +02: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
0c90da6638
Simplify code: failExecution can be replaced by closure raising exception (#795) 2019-08-06 13:12:59 +02:00
Marcus Holl
e954e3b629 unified behaviour for shell call rule (#794)
* Ensure closure gets called when neither returnStdout nor returnStatus are set

In this case we do not have a return value, but in case we execute a closure we should execute the closure.
With that it is possible to raise an exception from the closure.

* [refactoring] unify usage of unify method call

* Remove dead code.
Coding after uncondition throw exception statement does not get executed.

* Ensure script rule behaves the same whan called with string and with map.
2019-08-02 17:05:49 +02:00
Marcus Holl
e50aa9d37a Merge remote-tracking branch 'github/master' into HEAD 2019-07-18 10:21:25 +02:00
Marcus Holl
5c3307d71b Add hasSnippet 2019-06-27 12:20:59 +02:00
Marcus Holl
f6f1e0df5a fileExists also with map 2019-06-27 11:12:53 +02:00
Alejandra Ferreiro Vidal
c21a4a6a3e remove semikolons 2019-05-23 14:28:32 +02:00
Alejandra Ferreiro Vidal
79b79457f4 remove !#groovy header 2019-05-23 10:37:28 +02:00
Marcus Holl
f83935d248 Merge remote-tracking branch 'github/master' into HEAD 2019-05-17 12:05:34 +02:00
Christopher Fenner
c8f9db71eb
add step for Sonar scan (#183)
* add new step sonarExecute

* simplify list

* add general credentials for SonarQube

* Update default_pipeline_environment.yml

* Update sonarExecute.groovy

* correct worker invocation

* switch step/stage config order

* add tests

* add webhook handling

* Update default_pipeline_environment.yml

* use withMandatoryProperty with condition

* Update ConfigurationHelper.groovy

* Update sonarExecute.groovy

* Update ConfigurationHelper.groovy

* rename step to sonarExecuteScan

* rename step to sonarExecuteScan

* rename step to sonarExecuteScan

* Update sonarExecuteScan.groovy

* change return type

* Update sonarExecuteScan.groovy

* stash

* update defaults

* update install path

* use quiet unzip

* use long option names

* optimize filename retrival

* rework PR voting

* fix path

* remove accitentially checked-in file

* add documentation, optimise coding

* correct test case

* add documentation

* remove option prefix

* rename config variable

* update docs

* update docs

* rename download url

* fix typo

* adjust test cases

* add test cases

* update docs
2019-05-13 12:29:07 +02:00
Alejandra Ferreiro Vidal
5448385985 add multicloud deploy step 2019-04-12 17:51:38 +02:00
Christopher Fenner
e67b9cff23
influxWriteData: hold data in dedicated object (#624)
* add InfluxData object

* add InfluxData rule

* use InfluxData

* include jenkins_custom_data into InfluxData object

* correct typo

* add missing import

* fix condition for influx reporting

* add test class

* Update influxWriteData.groovy
2019-04-11 11:39:41 +02:00
Sven Merk
a43760d34a Use JenkinsCredentialsRule 2019-04-01 15:59:20 +02:00
Marcus Holl
5ad99599ab Make use of the step tracker 2019-03-27 16:02:04 +01:00
Marcus Holl
a42e727da2 Create step specific plugin lists: Helper class for tracking step calls
Before the test we remmber which test is currently running.
During the test we collect all the calls to steps.

Beside that we persist the names of all steps within this shared
lib itself.

After the test(s) we write a corresponding json file. In fact we
write the file after each test, which is too often. But since we
don't know which test is the last test we can't do better.

The resulting file can be used later on for resolving the plugins
contributing the particular steps.

With that we are able to create a list of required plugins for each
step.
2019-03-27 16:02:04 +01:00
Marcus Holl
5710ac48ec Introduce step helper 2019-03-27 15:54:25 +01:00
Sven Merk
1202f4f55a Added test 2019-03-12 23:22:27 +01:00
Sven Merk
03d3e2b241 Fix missing descriptor support 2019-03-04 15:02:01 +01:00
Marcus Holl
6b4d2ba33e Remove println statements from default registered sh closure
We should try to avoid promting statements to the log during tests. This is basically
some kind of manual/visual checking of conditions. This does not work since in most cases
nobody scans test logs manually/visually. I think this is often a smell for missing assertions.
2019-02-07 16:58:49 +01:00
Oliver Nocon
74366631b5
Project "Piper" Template: framework and structure (#476)
* Project "Piper" Template: framework and structure

This is the first in a series of Pull-Requests to provide a fully functional Pipeline template into the library.

This PR contains:
* general Pipeline structure incl. tests
* Pipeline initialization incl. tests
* Hollow pipeline stages incl. tests
* first set of default values
* add gitUrls to commonPipelineEnvironment
* set correct git information on commonPipelineEnvironment
2019-02-05 15:37:59 +01:00
Oliver Nocon
3b2e42c74f
Add step containerExecuteStructureTest (#441)
* add step containerExecuteStructureTest
* include PR-review feedback
* documentation
2019-01-31 09:39:13 +01:00
Daniel Kurzynski
6e26d78047
Improve neo deploy (#440)
The following features were added:
Lock resources for deployment
New parameters: environment, vmArguments
Assert password does not start with @
Link to cloud cockpit
Only execute rolling update if app is running
Show logs if deployment failed
Restart app after normal deployment
Use neo namespace for parameters
Align parameter names with neo sdk: size, application, source
Remove vmSize check as done by the tool itself
2019-01-28 11:32:24 +01:00
Marcus Holl
bf881bfc13 Merge remote-tracking branch 'github/master' into HEAD 2018-12-12 12:05:24 +01:00
Oliver Nocon
e556fba950
add wrapper for stages contained in library (#341)
* add wrapper for stages contained in library

`piperStageWrapper` provides a wrapper for stages which we may include into the library.
It will take care about extension capabilities, locking, node handling, ... which should be a capability of every stage contained in the library.
2018-12-12 11:45:11 +01:00
Marcus Holl
51afc894e5 Implement hashCode/equals/toString for JenkinsShellCallRule
* toString is helpful for troubleshooting during developing tests
* equals/hashCode are required in case somebody would like to register
  some responses again (e.g. register something valid almost all the time, and
  register something more specific for a certain test).
2018-12-10 16:23:24 +01:00
Oliver Nocon
455461d3c1
add step pipelineRestartSteps (#337)
This step allows to restart a set of steps in order to retry in case of e.g. infrastructure failures which first need to be fixed.

* update documentation
2018-10-18 08:51:48 +02:00
Oliver Nocon
1f8b94528c
add step mailSendNotification (#336)
This step allows to send email notifications in case of pipeline failures.
2018-10-17 12:05:11 +02:00
Marcus Holl
9cd31e7236 Merge remote-tracking branch 'github/master' into HEAD 2018-09-21 13:27:29 +02:00
Marcus Holl
123ce3a603 Merge remote-tracking branch 'github/master' into HEAD 2018-09-21 11:20:14 +02:00
Marcus Holl
c1900f6ecd Remove output to stdout from tests
In fact nobody reads it, but on some IDEs it is shown when tests are executed.
2018-09-14 09:08:52 +02:00
Marcus Holl
dc9ce9a732 Remove generic gitUtils from BasePiperTest
there is only one test class making use of it left. This test class is the
GitUtilsTest itself.

Hence moving this member downwards in the test class hierarchy into GitUtilsTest.

I doubt it makes sense to make use of a generic git utils mock somewhere else since this basically
means to test the GitUtils class in the conxtext of other examinees. For that there is no need.
The GitUtils class should be tested by the corresponding test class, but not in a transive manner
by other tests. For all other tests a specific git utils mock should be provided mocking the corresponding
method class. This is already the case today, otherwise we would have more test classes making use
of the generic git utils mock.
2018-09-13 16:01:35 +02:00