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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAKzFqnPUNHyZOjQztGKkTKuA7d27oYgj0AqgHfh94Ehs6E6Rug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to