Here's a snippet from a Jenkinsfile in a pre-2.0 pipeline job that I use
to read an existing build.properties file in the workspace so that the
Jenkinsfile can use the properties. I haven't tried this in 2.0 pipeline
yet.
if (!fileExists('build.properties')){ echo 'No
build properties.' exit } def props =
readProperties file: 'build.properties' /* * From build.properties
file */ def Var1= props["SOME_PROPERTY"] def Var2=
props["ANOTHER_PROPERTY"]
On Wed, Sep 21, 2016 at 8:22 AM, Pete Singleton <[email protected]>
wrote:
> Hi, I'm having exactly the same issue (having only started with Jenkins
> 2.0 in the last couple of days). I've tried the Pipeline Utility, tried
> the EnvInject plugin, also tried opening the file using Groovy file
> operations, no success! Did you manage to solve this??
>
> On Thursday, 8 September 2016 21:50:01 UTC+1, Ian Cotton wrote:
>>
>> Thanks Jerome. Unfortunately this doesn't help me much. The properties
>> file I need to load already exists and is in use by various build scripts.
>> I assume I need to create an EnvInjectJobProperty object and set the
>> appropriate property on it. I'll give that a try.
>>
>> On Wed, Sep 7, 2016 at 7:07 PM <[email protected]> wrote:
>>
>>> Not sure about the Java properties file, but I succeed by doing a
>>> .groovy file if that's interest you (probably not, but here it is if
>>> someone need it, it's unsafe but in controlled env it doesn't matter):
>>>
>>> *Jenkinsfile*
>>> def my_var = evaluate(new File("myEnv.groovy"));
>>> bat "\"${my_var.python_2_exe}\" myscript.py"
>>> ...
>>>
>>> *myEnv.groovy*
>>> def rv= [:]
>>>
>>> rv['mercurial_url'] = 'http://mercurial.buildserver/'
>>> rv['python_2_exe'] = "c:\\Python27\\python.exe"
>>> ...
>>> return rv;
>>>
>>> I put the .groovy file on the build machine jenkins folder, so the
>>> Jenkinsfile from the repos can work with vars from any of our build
>>> machines or network emplacement.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Jenkins Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/jenkinsci-users/1a03bb2f-5022-4005-ab10-5e3146aebcd1%
>>> 40googlegroups.com
>>> <https://groups.google.com/d/msgid/jenkinsci-users/1a03bb2f-5022-4005-ab10-5e3146aebcd1%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/jenkinsci-users/fcf3de22-08c3-47e2-b996-1d0bd85f28ed%40googlegroups.
> com
> <https://groups.google.com/d/msgid/jenkinsci-users/fcf3de22-08c3-47e2-b996-1d0bd85f28ed%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/CAAYHPVij13azLVN%2BwkQfeGG_ExE6eUqGE1A4cL9Dg-zvwtXK0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.