Pass in a parameter/property specified by Jenkins job, not user

41 views
Skip to first unread message

Adam Hardy

unread,
Aug 24, 2018, 11:47:14 AM8/24/18
to Jenkins Users
Hi

I'd like my Jenkins multi-branch and pipeline jobs to pass in a pre-defined parameter or property to the build script in the git repo specified.

This isn't for user input. I'm trying to improve the capabilities of a microservices-oriented CD pipeline I inherited.

I want to set up more or less the same job 3 times for each app / git repo: once for devtest, once for oat and once for prod.

I'll use it to extract a set of configuration parameters from a yaml file in the repo, which will specify stuff like deployment namespace, app, version, docker registry url, credential id etc.

At the moment, I can only see how I can change the git repo details or ask the user the input.

Thanks
Adam



Qiang

unread,
Aug 25, 2018, 11:51:14 PM8/25/18
to Jenkins Users
Is the only purpose of the parameter/property to differentiate between the devtest/oat/prod?
If that's the case, can you use ${env.JOB_NAME} ?

Adam Hardy

unread,
Aug 26, 2018, 8:15:27 AM8/26/18
to jenkins...@googlegroups.com
I can't check until I get in on Tuesday but this is a multi-branch pipeline job.

Won't env.JOB_NAME either be the approximately the name of the repo so I know
which app it builds, or the name of the branch in that repo?

If it's the former, I guess I could suffix the name with the environment and
then parse it in the script, but that's not really something I'd like.


Qiang Ma

unread,
Aug 26, 2018, 10:20:22 AM8/26/18
to jenkins...@googlegroups.com
Hmm, JOB_NAME would be auto generated based on the branch name.

User input would make the job pause, so that doesn't seem a good option , either.

Then what else can be different to make the same job performing different deployment?  Branch name? 


--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/4jayfI5ijBQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/74a0e435-3ac7-e14e-0d0b-7858080a3de8%40cyberspaceroad.com.
For more options, visit https://groups.google.com/d/optout.


--

Regards,
Qiang

Adam Hardy

unread,
Aug 26, 2018, 11:42:05 AM8/26/18
to jenkins...@googlegroups.com
Yes, exactly, I don't think pausing the job to get the info from the user is a
good way of doing it.

If it isn't possible to pass an extra parameter/property from the Jenkins UI to
the script on job launch and initialization, then I should move onto a different
approach using some other logical means.

However the "parameterized build" option in the job config dialog gave me hope
that such a non-user-defined parameter was feasible.

Is that incorrect?


Qiang Ma wrote on 26/08/18 15:20:
Hmm, JOB_NAME would be auto generated based on the branch name.

User input would make the job pause, so that doesn't seem a good option , either.

Then what else can be different to make the same job performing different
deployment?  Branch name?


On Sun, Aug 26, 2018 at 7:15 AM Adam Hardy <adam....@cyberspaceroad.com
<mailto:adam....@cyberspaceroad.com>> wrote:

  I can't check until I get in on Tuesday but this is a multi-branch pipeline
job.

  Won't env.JOB_NAME either be the approximately the name of the repo so I know
  which app it builds, or the name of the branch in that repo?

  If it's the former, I guess I could suffix the name with the environment and
  then parse it in the script, but that's not really something I'd like.


  --
  You received this message because you are subscribed to a topic in the
  Google Groups "Jenkins Users" group.
  To unsubscribe from this topic, visit
  https://groups.google.com/d/topic/jenkinsci-users/4jayfI5ijBQ/unsubscribe.
  To unsubscribe from this group and all its topics, send an email to
  jenkinsci-use...@googlegroups.com
  <mailto:jenkinsci-users%2Bunsu...@googlegroups.com>.
  To view this discussion on the web visit
 
https://groups.google.com/d/msgid/jenkinsci-users/74a0e435-3ac7-e14e-0d0b-7858080a3de8%40cyberspaceroad.com.
  For more options, visit https://groups.google.com/d/optout.



--

Regards,
Qiang

--
You received this message because you are subscribed to a topic in the Google
Groups "Jenkins Users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/jenkinsci-users/4jayfI5ijBQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
jenkinsci-use...@googlegroups.com
<mailto:jenkinsci-use...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/CAHf%3Dn4yNObgShHRmO%2B6_c_Zr-jtnKApK-T%3DWLu%2B-cd4s4z3d8g%40mail.gmail.com
<https://groups.google.com/d/msgid/jenkinsci-users/CAHf%3Dn4yNObgShHRmO%2B6_c_Zr-jtnKApK-T%3DWLu%2B-cd4s4z3d8g%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Adam Hardy

unread,
Aug 28, 2018, 5:38:33 AM8/28/18
to Jenkins Users
I think I can use env.JOB_BASE_NAME

Failing that I can give different jobs different script paths, and call other scripts with parameters.
Reply all
Reply to author
Forward
0 new messages