'How to println from a txt file in jenkins

So I have a file called "text1.txt" that has only one line -

version.build=846 

I want to do something like this-

def svntag = ccsmp_v_ {version.build}
println $svntag

ccsmp_v_846

Is there any way to do this ?



Solution 1:[1]

You can read a file from the workspace using the methods from pipeline utility steps plugin.

For your case it would be best to use readProperties method, for example:

def properties = readProperties file: '<your properties file in the workspace>'

Then you can access the value with:

def svntag = "ccsmp_v_${properties['version.build']}"

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 VANAN