We've got a technique for this at our shop.  It requires the envInject plugin.

You write a line such as:

echo "varID = $varID" > export_props.properties

In the step after the shell step, create an "Inject environment variables" step 
that reads from export_props.properties.

Now, the contents of export_props.properties is injected into the job itself, 
and will be injected into shell steps as environment variables.

--Rob

From: [email protected] 
[mailto:[email protected]] On Behalf Of Naumenko, Roman
Sent: Thursday, January 23, 2014 10:50 AM
To: [email protected]
Subject: Variable from shell script to Jenkins job

Jenkins experts,

Does anybody remember how to pass variable from shell execution inside the job 
to Jenkins itself?

Say there is pre-step:
varID=(grep something ${WORKSPACE}/pom.xml | cut something else)

Is it possible to use $varID in further non-shell steps in the job?

--Roman

_______________________________________________________________________

This email is intended only for the use of the individual(s) to whom it is 
addressed and may be privileged and confidential.
Unauthorised use or disclosure is prohibited. If you receive This e-mail in 
error, please advise immediately and delete the original message.
This message may have been altered without your or our knowledge and the sender 
does not accept any liability for any errors or omissions in the message.

Ce courriel est confidentiel et protégé. L'expéditeur ne renonce pas aux droits 
et obligations qui s'y rapportent.
Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il 
contient par une personne autre que le (les) destinataire(s) désigné(s) est 
interdite.
Si vous recevez ce courriel par erreur, veuillez m'en aviser immédiatement, par 
retour de courriel ou par un autre moyen.
--
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]<mailto:[email protected]>.
For more options, visit https://groups.google.com/groups/opt_out.

The information in this message is for the intended recipient(s) only and may 
be the proprietary and/or confidential property of Litle & Co., LLC, and thus 
protected from disclosure. If you are not the intended recipient(s), or an 
employee or agent responsible for delivering this message to the intended 
recipient, you are hereby notified that any use, dissemination, distribution or 
copying of this communication is prohibited. If you have received this 
communication in error, please notify Litle & Co. immediately by replying to 
this message and then promptly deleting it and your reply permanently from your 
computer.

-- 
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].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to