Why?
On Wednesday, June 14, 2017 at 5:33:26 AM UTC-7, Mark Allison wrote:
>
> Thanks for the reply, but I need to set the variable outside the pipeline
> script similar to the Environment Injector plugin. Is there a way to do
> that?
>
> On Tuesday, 13 June 2017 13:36:07 UTC+1, Kevin Burnett wrote:
>>
>> here's an example Jenkinsfile that sets an environment variable
>> (REPO_URL) that applies to all stages. you can also use the withEnv step to
>> set an environment variable for a certain block.
>>
>> pipeline {
>> agent { label 'docker' }
>> environment {
>> REPO_URL = 'www.my.repo'
>> }
>> stages {
>> stage('build') {
>> steps {
>> sh 'env | grep REPO_URL'
>> }
>> }
>> }
>> }
>>
>> Jenkinsfiles apply to all branches in a repo, so that part is handled
>> implicitly.
>>
>> Hope this helps,
>> KB
>>
>>
>> On Tuesday, June 13, 2017 at 3:53:33 AM UTC-4, Mark Allison wrote:
>>>
>>> I have a Jenkins multibranch pipeline project and I want to set an
>>> environment variable for all branches. Is this possible? I could only see a
>>> way to do it with the environment injector plugin at the branch level. I
>>> want to be able to do this at the project level because I want new feature
>>> branches to automatically inherit some environment variables.
>>>
>>
--
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/3f7e72cf-a497-4976-a7f4-03cf80dbc635%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.