How about writing the value to a temporary file instead? A shell
script could use the file later on (in another stage) to set the
environment variable.

On Wed, Apr 14, 2021 at 9:01 PM [email protected]
<[email protected]> wrote:
>
> hey, all!
>
> Here's what I would like to do:
>
> 1. in the pipeline itself, create an environment variable.
> 2. pass that environment variable to a job
> 3. that job will overwrite the environment variable's value at the top level
> 4. a later job will use this new value within its execution.
>
> something like:
>
> pipeline {
>     agent {
>         label 'Computer'
>     }
>
>     environment {
> 1.        pipelineVariable = "15"    3. (after the changeVariableValue job, 
> variable value is now 7)
>     }
>
>     stages {
>         stage('change variable value') {
>             steps {
>                 script {
> 2                    build job: changeVariableValue
>                     parameter: [[$class: 'StringParameterValue', name: 
> 'PipelineVariable', """${pipelineVariable}"""]]
>                }
>             }
>         }
>         stage('new variable value') {
>             steps {
>                 script {
> 4                    build job: newVariableValue                              
>                                                                               
>   parameter: [[$class: 'StringParameterValue', name: 'PipelineVariable', 
> """${pipelineVariable}"""]]
>                }
>             }
>         }
>     }
> }
>
> The jobs are written in Powershell.
>
> Is there a way to do this?
>
>
> --
> 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/13fe1896-18d5-4566-99b6-5b1044b7934cn%40googlegroups.com.



-- 

Look, that's why there's rules, understand? So that you think before
you break 'em.

    -- (Terry Pratchett, Thief of Time)

-- 
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/CAF8HOZJF0xeVXFagZwxDQvgrWroi%3DC%2BsQXhDkQ5KJmnDcHWteQ%40mail.gmail.com.

Reply via email to