How to share (non-secret) variables between jobs

29 views
Skip to first unread message

Ashish Sharma

unread,
Sep 9, 2020, 8:46:51 PM9/9/20
to Jenkins Users
Dear All,

We have a bunch of jobs which will use some common variables like user names, urls etc (which are not secrets or credentials). Is there a way (or plugin maybe) to share these variables between jobs (something like credentials plugin for secrets).

TIA,
Ashish

john levin

unread,
Sep 9, 2020, 9:59:54 PM9/9/20
to jenkins...@googlegroups.com
Simply parsing the required variables while triggering the downstream job.

stage ('Invoke_pipelineA') {
            steps {
                build job: 'pipelineA', parameters: [
                string(name: 'param1', value: "value1")
                ]
            }
        }
        

/BR
John

--
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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/cb539948-33ce-4233-b5bc-965bbfd0d265n%40googlegroups.com.

Ashish Sharma

unread,
Sep 9, 2020, 10:29:04 PM9/9/20
to Jenkins Users
Hi John,

We don't have dependent (upstream-downstream) pipelines, these pipeline are in same hierarchy and triggered separately.
But since these are microservice for same project, we want to share some variables among these.

john levin

unread,
Sep 9, 2020, 11:43:43 PM9/9/20
to jenkins...@googlegroups.com
Oh.. in that case I guess you have to handle it in your scripts only, if the values are dynamically created in one job and you have to pass to another which is not dependant.

May be you can check the job status and check if its running and then get some values from logs.


Gianluca

unread,
Sep 10, 2020, 2:44:11 AM9/10/20
to Jenkins Users
You could maybe use https://www.jenkins.io/doc/book/pipeline/shared-libraries/ and load those variable from a global shared library and used inside the pipelines.

Ashish Sharma

unread,
Sep 11, 2020, 11:16:31 PM9/11/20
to Jenkins Users
Thanks All, we are now saving these variables in shared groovy files and loading file in job pipeline to read variables. 
Reply all
Reply to author
Forward
0 new messages