Closed tutschc closed 4 years ago
Could you please describe what you want to do with the variable NODE_ENV? In you examples I could not find a reference to it. In general it should be possible to send environment variables via the extension mechanism https://sap.github.io/jenkins-library/extensibility/#1-extend-individual-stages:
void call(Map params) {
withEnv["NODE__ENV=XYZ"]{
//execute original stage as defined in the template
params.originalStage()
}
}
return this
As an alternative I guess you could also set end environment variable via the npm script in the package.json:
"scripts": {
...
"ci-frontend-unit-test": "NODE_ENV=build karma xyz ..."
}
We have performance problems with frontent tests. Due to this we serve the UI5 resources (https://sapui5.hana.ondemand.com/1.56.10) on our own, local and on build environment. Due to the different url on local and build environment we need the NODE_ENV to recognize when we are running in build environment. We would prefer not to use any extension machanism.
And what about setting the environment variable in the package.json as described above as alternative. For this you would not have to use extensions.
If we set the NODE_ENV hard in the package.json as described it would no longer be possible to execute the script in local environment.
Well the idea would be to use the ci-* scripts only in the ci pipeline and have an additional script without the ci- prefix and without the environment variable.
We try your solution. Thanks.
Issue Description (Mandatory)
The pipeline is failing in the stage: frontendIntegrationTests, frontendUnitTests
We are using this pipeline to build maven projects with a frontend written with ui5. During frontend unit- and integration testing, we would like to set the environment variable
NODE_ENV
toBUILD
. Currently, we cannot do this by setting options in .pipeline/config.yml (as far as we know), so we have to extend both stages. It would be great if this was possible using only the configuration file. Apparaently, the piper library already supportsdockerEnvVars
in the stepnpmExecute
, but currently the step is not used in this pipeline lib.We think this change is easy to implement: Changing
to
in
stageFrontendIntegrationTests.groovy
and similarlyto
in
stageFrontendUnitTests.groovy
and adding the default optionto
default_s4_pipeline_environment
was sufficient to run our pipeline. The only problem is the configuring of the virtual frame buffer (Xvfb -ac :99 -screen 0 1280x1024x16
), which cannot be passed tonpmExecute
of the piper library. As a workaround, we included this command in the npm script. We did not open a pull request, as a clean solution would include this command in the docker image or in the piper project.Search for existing solution beforehand (Mandatory)
Please try the GitHub search, it works really well
Project Details (Mandatory)