How to set global variable from pipeline job?

I have set few variables in the pipeline.

If the variable PACKAGEPATH set, then only the build stage will run.

I want to add one more stage before build as prebuild and add a job there.
So, if the PACKAGEPATH is not set then the job in prebuild stage would run code and need to set the variable there.

But, how to set the variable from one job and make that variable available to other jobs?

Hi @uday.reddy3

passing variables between jobs is done using artifacts. You save your variable to a file and use it in another job.

I kept conditions to further stages to run only when PACKAGEPATH variable is passed.

So, as a first stage, I want to add one more job and set the value for that variable.

But with artifacts it is not possible right.

Modifying global variables from the job scope is not possible. Another way of achieving the jobs being built, and additional global variables being conditionally set, could be using workflow:rules:variables.