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

64 Commits

Author SHA1 Message Date
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
Marcus Holl
8afec9b4dc Merge remote-tracking branch 'github/master' into HEAD 2018-09-12 11:14:03 +02:00
Marcus Holl
9e378d6b46 Remove obsolete code: mockHelper
in fact the MockHelper seems not to be used anymore. Apparently fully
superseded by our JenkinsRules.
2018-09-10 13:44:42 +02:00
Marcus Holl
cce1eb0f9a Execute closures when evaluating shell calls
This allows us to e.g. also throw exceptions (e.g. hudson.AbortException) when dealing with
mocked shell calls.
2018-09-07 15:27:55 +02:00
Marcus Holl
6b7dc48c44 Be more flexible with JenkinsReadYaml rule
When we register a closure as file, the closure will be exectutd.
Otherwise we return what is registered.

This gives us a maximum level of flexibility. We can throw exceptions (e.g. FileNotFound) as
as test setup requires this, in simple cases we provide the yaml as a string.
2018-09-04 09:46:59 +02:00
Marcus Holl
fb425a4c70 Register empty pipeline config yml by default 2018-09-03 15:43:17 +02:00
Marcus Holl
26ecbe5013 Provide option for registering file for read yaml.
We can now registering files to JenkinsReadYamlRule by
providing the file name alongside with the expected content
(or e.g. an expception)

With that change it is possible to remove pwd statements
from mtaBuild. These statements was used in order to pass
a temporary directory inside the mtaBuild (code under test).
This is not needed anymore since we can register the files
directly.

Having pwd implies working with absolute pathes which is
also a no-go when working with docker, since the absolute
pathes inside and outside docker are normally not the same.

For pathes relative to a build root directory it is rather
easy to keep the pathes consistent the same.

Adjust sources according to registering yaml file to jenkins rule.

For mtaBuild this means also: get ride of absolute pathes for denoting the yaml file.
Having absolute pathes makes it difficult/impossible to work also with dockerized versions
of mtaBuild since the absolute pathes are most probably not the same inside and outside
the docker container, but the relatives pathes can be kept the same easily.
2018-09-03 15:43:15 +02:00
Marcus Holl
5cca5fddbb Tests: make use of JenkinsCredentialsRule
JenkinsCredentialsRule now closer to reality since it mimics
the bevavior or the credentials plugin in case a credential
is not known.
2018-09-03 12:28:08 +02:00
Marcus Holl
8a019f5b86 Remove read yaml rule from common rules
read yaml rule is a very frequently used rule. But having the rule in the common rules
means we cannot register text or files to that rule, which makes it less handy to work
with yaml files in the tests.
2018-08-31 10:22:46 +02:00
Ramachandra Kamath Arbettu
c84114c3df
Enable support for executing on K8S as a step (#231)
* Create executeDockerOnKubernetes.groovy

* Update dockerExecute.groovy

* Create SysEnvTest.groovy

* Update default_pipeline_environment.yml

* Update executeDockerOnKubernetes.groovy

* Create utils object

* update docker image

* Update mavenExecute.groovy

* Use pipeline-lib than piper

* Check container name

* Always change ownership to 1000

* Check for map

* Fix command

* Move chmod to docker execute

* Use generic name for the pod

* runAsPod has been added

* Return false if script has no k8smapping

* fix syntax error

* Null checks

* Returnn dockerImage name

* Check method body

* Return container name

* Cleanup echos

* Use runAsPod

* Rename step

* Use official jenkins JNLP agent image

* Construct containersMap

* Check if kubernetes plugin is active

* Support JaaS

* pass script object

* Move configuration to default section

* Use generic flag to check if running in k8s

* fix jnlp agent name

* Solve travis errors

* Improvements to config and changes to name of the method

* Improvements to config

* Fix type

* Rename stash config

* add import

* Fix map order

* Fix jnlp agent name

* cleanup config usage

* Check if config is enabled

* Use nested k8s mapping

* Support custom docker workspace and move flag to env

* Feature/k8s stage (#1)

* Use nested k8s mapping

* Support custom docker workspace and move flag to env

* Check dockerOptions value

* Support local execution

* Add tests for dockerExecute

* Move config to step and Fix tests

* Use step configuration while running as a pod

* Streamline parameter and config initialization

* Streamline parameter and tests

* Cleanup and align variable name

* Use default JNLP agent if one not defined in config

* Add tests for runInsidePod. Ensure lowercase container names.

* Improve tests and remove unused code block

* Fix permission issues

* Perform stashing and unstashing inside container

* Use custom jnlp agent due to user id restriction

* Fix tests after jnlp agent change

* Address review comments

* Initialize script to default value if null

* Address review comments

* Update exeception handling and documentation

* Improve documentation

* correct indent

* Link documents to the index page

* Merge containerExecute and dockerExecuteOnKuberenetes step and address comments.

* Update dockerExecute.md

* Update dockerExecuteOnKubernetes.md

* Update default_pipeline_environment.yml

* update documentation

* Update documentation. Use annotation for singleton

* Update DockerExecuteOnKubernetesTest.groovy

* Update dockerExecute.groovy

* Update dockerExecuteOnKubernetes.groovy

* Improve documentation and test case names

* neoDeploy: switch to chained ConfigurationHelper (#244)

* switch neoDeploy to chained ConfigurationHelper

* update imports

* Improve tests

* Address review comments

* Improve documentation

* made dockerImage non-mandatory parm, improved test

* add comment regarding userid assumption
2018-08-21 15:45:59 +02:00
Oliver Nocon
65b582dc9d
artifactSetVersion - add new artifact types & cleanup (#242)
* artifactSetVersion - add new artifact types & cleanup

added:
* dlang
* golang
* npm
* pip
* scala

* add documentation update
2018-08-08 22:21:26 +02:00
Marcus Holl
ab0a0c6882 Introduce CredentialsRule
Instead of configuring the credentials setup

  o withCredentials
  o usename

in each of our tests (for the moment change-management related)
we collect the common coding in a JUnitRule.
2018-07-18 12:45:30 +02:00
Marcus Holl
c1927da33f [fix] misplaced quotation mark in assertion message 2018-07-12 08:12:32 +02:00
Marcus Holl
239e8cc054
Merge pull request #199 from marcusholl/pr/supportAssertOfLogMessageInCaseOfFailures
Support check for log messages in case of exceptions in code under test
2018-07-11 12:29:21 +02:00
Christopher Fenner
aa865f145f
Merge pull request #172 from SAP/CCFenner/mtaVersioning
add versioning for MTAs
2018-07-11 11:53:20 +02:00
Marcus Holl
111802cfd2 Support check for log messages in case of exceptions in code under test
With the current approach of checking log entries we are not able to
check log entries in case of a failure. But is is important to assert
log messages in case of a failure. Having reasonable log messages
simplified troubleshooting.

Hence we add JenkinsLoggingRule.expect(substring) and check after the
base of that rule has been called.

This interfears with other rules also working with an expect approach,
like e.g. ExpectedException. Which violation is presented depends on
the order or the rules around the test case.
2018-07-10 17:34:58 +02:00
Roland Stengel
b00a8c203a restore tracked methods on afterTestMethod 2018-07-02 14:03:41 +02:00
Marcus Holl
dd456f0d00 Return a return value based on a regex comparism
Comparism on plain string level gets complicated for complex commands and means
an implict check for an exact version of a command line. There are cases where
such an exact check is not desired, e.g. there is nothing wrong with having the
order of arguments variable.
2018-06-28 13:38:48 +02:00
Christopher Fenner
a93443ebdf add MTA versioning class 2018-06-27 11:08:09 +02:00
Marcus Holl
599e8dedbc
Merge pull request #149 from marcusholl/pr/improveShellCallRuleReturnValues
fix: apply same script transformation when registering script and whe…
2018-06-11 09:49:52 +02:00
Oliver Nocon
f8e5733486 speed up tests
* use new base class for testing
* initialize jenkins unit test framework only once for all test classes
* minor test cleanups
2018-06-06 11:19:19 +02:00
Thorsten Duda
fed20184b4 fix maven execute test 2018-05-30 12:30:26 +02:00
Oliver Nocon
9d0e7eaf4e add steps for file stashing 2018-05-30 12:00:13 +02:00
Marcus Holl
e8ced708f6 fix: apply same script transformation when registering script and when quering
avoids trouble in case of multi line scripts.
2018-05-11 14:21:22 +02:00
Christopher Fenner
0ba1a2c594
add JenkinsEnvironmentRule 2018-02-28 11:54:52 +01:00