'Jenkins : Decrypt a file inside a pipeline

I am currently facing an issue and cannot find a proper answer on internet.

In my jenkins directory I have a file with a lot of confidentials data such as username and passwords. I need to encrypt it and be able to use these data inside a pipeline.

I was thinking of encrypting it and add the key inside jenkins credential but I am not sure if it is a good idea or not.

Do you have ideas about how I can perform this operation in the most secure way ?

Thank you in advance for your answer !



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source