Hello,

To load a properties file, you can install this plugin :
https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Utility+Steps+Plugin
Then, you will have access to *readProperties* utility step. See
https://github.com/jenkinsci/pipeline-utility-steps-plugin/blob/master/docs/STEPS.md
for usage

IIUC your case, it will be worthwhile to create a method translating
properties to build parameters.

Moreover, for maintenance easiness, the best is to create Shared Libraries
<https://jenkins.io/doc/book/pipeline/shared-libraries/> to declare common
steps for all yours pipelines in a centralized way.

My 2 cents

2017-08-24 21:43 GMT+02:00 AJ Ferrigno <[email protected]>:

> Hello,
>
> I am trying to move towards Pipelines instead of our Build Flow /
> Parameterized Trigger plugin setup. It is mostly making sense, but there is
> one thing that seems very cumbersome / maybe even impossible under
> Pipelines which I can do with ease via the Parameterized Trigger plugin
> (see documentation here
> <https://wiki.jenkins.io/display/JENKINS/Parameterized+Trigger+Plugin>).
>
> I like the concept of being able to trigger another job, and specify a
> properties file (each line is in the format x=y) somewhere in my job's
> workspace which automatically become the parameters of the next job in the
> sequence. It would be awesome to have this functionality exist somewhere in
> Pipelines as a step or some one-liner I could use.
>
> For example, say I have this pipeline (basically: create parameters for a
> deploy, then deploy using those parameters):
>
>>
>> pipeline {
>>     agent any
>>
>>     stages {
>>         stage('Parameters') {
>>              steps {
>>                 build job: "DeployParameters", parameters: [string(name:
>> 'project', value: project), string(name: 'branchName', value: branchName)]
>>                 /* grab artifact file "artifact.txt" from
>> "DeployParameters" job and set a bunch of variables based on it */
>>                 }
>> }
>>         stage('Deploy') {
>>              steps {
>>                 build job: "DeployJob", parameters: /* pass in all
>> parameters set above */
>>              }}}}}
>
>
> First of all, looking at the commented lines, is the above possible at
> all, using a step or otherwise? I tried using the below code to do
> something similar, but it (Jenkins v2.74) complained "Scripts not permitted
> to use new java.util.Properties"
>
> step([$class: 'CopyArtifact',
>>          filter: 'artifact.txt',
>>          projectName: "DeployParameters"])
>> script {
>>          def content = readFile 'artifact.txt'
>>          Properties properties = new Properties()
>>          InputStream is = new ByteArrayInputStream(content.getBytes());
>>          properties.load(is)
>>          def runtimeString = 'variable_i_want'
>>          variable_i_want = properties."$runtimeString" }
>
>
> I know I can probably tell my Jenkins installation to allow
> java.util.Properties, but that seems like an unsustainable hack. I don't
> think I'm doing anything terribly insecure here, so I would really like to
> be above-board about it.
>
> Second, even if I could get the above code to work, it is simply too long
> and un-maintainable. Especially since I would probably be re-using this
> many times, it would be awesome to replace this functionality in the
> Parameterized Trigger plugin with a simple one-liner. It may even help
> somebody else somewhere.
>
> Has anybody else needed something like this? If this is a feature request
> not currently thought of, what would it take to get this solution developed?
>
> Thanks for any help,
> AJ
>
> --
> 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/CAKzFqnPUNHyZOjQztGKkTKuA7d27o
> Ygj0AqgHfh94Ehs6E6Rug%40mail.gmail.com
> <https://groups.google.com/d/msgid/jenkinsci-users/CAKzFqnPUNHyZOjQztGKkTKuA7d27oYgj0AqgHfh94Ehs6E6Rug%40mail.gmail.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/CAPO77c1FYk93e37Lr7o7sheP2kG%3DvYFEa903_tJgJEnEFzg36Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to