I want to have common environment variables through all my pipelines. I am using a Shared Library, so I was wondering, how can I put constant values into a shared library and use it in any pipeline.
Is there a way to put it in the src directory, or vars, and use it in a pipeline without creating an object in a pipeline? I tried both but was unsuccessful.
Thank you and best regards,
To use global values in your jenkins pipelines, you can makes use of global envs or configuration files in
/resourcesGlobal Environment Variables
These are configured on a jenkins level, and can be accessed from any pipeline on the instance (regardless of the use of a shared library)
This is answered in detail here https://stackoverflow.com/a/41235654/22666765
Shared Library Configuration
A config file can be added (of any format) to the /resources folder in your shared library. This can then be read using the
libraryResourcefunction provided by Jenkins https://www.jenkins.io/doc/pipeline/steps/workflow-cps-global-lib/#libraryresource-load-a-resource-file-from-a-shared-libraryOnce the file is read, your values can be parsed & loaded into variables on the pipeline level