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

43 Commits

Author SHA1 Message Date
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
Christopher Fenner
be26c8dc1e
add JenkinsStepRule 2018-02-28 11:54:39 +01:00
Alejandra Ferreiro Vidal
9dafdd1cc0 mtaBuild with new config framework 2018-02-08 13:26:48 +01:00
Oliver Nocon
fbd03a88da
Step for automatic versioning (#65)
It contains:

* versioning step artifactSetVersion
* versioning implementation for Maven & Docker
* enhancements to commonPipelineEnvironment
* extended default configuration
* new utils object for git-related tasks
* automated tests incl. new Rules and resources
* incorporated PR feedback
* step documentation
2018-02-07 13:17:33 +01:00
Alejandra Ferreiro Vidal
4f624d5aea add error rule as common rule 2018-02-01 10:11:37 +01:00
Marcus Holl
ef0b1bd9dd [refactoring] Rule handling
Starting point for that refactoring: it turned out that the tests
was not independent. The DefaultValueCache which is a singleton
keeps the status over various tests. Success of test execution depends
on the order test execution.

We have now
  * a dedicated rule for resetting the default value cache
  * JenkinsConfiguration rule (which already provided facilities for
    dealing with the configuration) has been replaced by a readYaml rule.
    From the PipelineUnit test framework we get already a handler for
    libraryResource, which is also part of the setup of the default
    values.
  * An auxiliar class which combines the
      * JenkinsSetupRule (registers the lib)
      * JenkinsReadYamlRule (provides facilities for Yaml parsing)
      * JenkinsResetDefaultValueCacheRule (cleans up the DefaultValueCache)
    into a rule chain. By using this rule chain we ensure that our
    setup OK (piper lib registered, and default config can be setup in
    a clean way).
2018-01-29 09:42:23 +01:00
Marcus Holl
0d87348c21 Replace JenkinsConfigRule by more speaking readYaml rule
and reset default cache rule.
2018-01-29 09:42:23 +01:00
Thorsten Duda
e8363e9637 introduce JenkinsConfigRule 2018-01-23 15:02:25 +01:00
Marcus Holl
106a8b4693 Make use of JenkinsShellCallRule 2018-01-23 15:02:25 +01:00
Thorsten Duda
1089e192f3 added JenkinsShellCallRule class 2018-01-23 14:51:18 +01:00
Marcus Holl
00df52f9f1
Merge pull request #49 from marcusholl/pr/changePiperLibIdentifier
Change piper lib identifier
2018-01-17 09:28:11 +01:00
Marcus Holl
a794e9270b remove printing the callstack
I guess nobody is interested in the callstack printed into the log
during the tests.
2018-01-16 09:49:19 +01:00
Marcus Holl
2a7a35db29 [refactoring] Remove redundant code 2018-01-16 09:43:24 +01:00
Marcus Holl
998abed377 Switch library identifier to piper-library-os
this identifier is commonly used.
2018-01-15 15:06:02 +01:00
Sven Merk
fe89155a04
Initial check-in of lesfurets test improvements (#23)
Adding lesfurets test framwork improvements via helper classes
2018-01-10 10:27:55 +01:00