-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-13230] Not able to use Jenkins Environment Variables and variables injected through Env Inject plugin when executing commands over ssh in Publish over SSH plugin #222
Comments
bap: The following is the output (on a windows master, Jenkins 1.456) from a job that injects variables from "Prepare an environment for the run", "Build Environment" and from an "Inject environment variables" build step. Started by user anonymous [EnvInject] - Variables injected successfully. [EnvInject] - Variables injected successfully. [EnvInject] - Variables injected successfully. |
I tested by setting variables using the "Properties Content" textarea. It did not work for me. I am using Jenkins 1.456 on a RHEL Linux machine. You can see from below that MODULE_TEST and DEPLOY_DIRECTORY are injected during build time but not replaced during promotion. Build Log: Started by user anonymous if ("ACCT".equals(MODULE_NAME)) { def map = [MODULE_HOME: "SSP-AM"] ; return map }if ("ATTCH".equals(MODULE_NAME)) { def map = [MODULE_HOME: "Attachments"] ; return map }if ("CCM".equals(MODULE_NAME)) { def map = [MODULE_HOME: "SSP-CCM"] ; return map }if ("DNG".equals(MODULE_NAME)) { def map = [MODULE_HOME: "SSP-DNG"] ; return map }if ("DR".equals(MODULE_NAME)) { def map = [MODULE_HOME: "SSP-DR"] ; return map }if ("FPD".equals(MODULE_NAME)) { def map = [MODULE_HOME: "SSP-FPD"] ; return map }if ("FPD_PRINT".equals(MODULE_NAME)) { def map = [MODULE_HOME: "SSP-FPD"] ; return map }if ("RDM".equals(MODULE_NAME)) { def map = [MODULE_HOME: "SSP-RDM"] ; return map }if ("REPORTS".equals(MODULE_NAME)) { def map = [MODULE_HOME: "SSP-Reports"] ; return map }if ("UMS".equals(MODULE_NAME)) { def map = [MODULE_HOME: "SSP-UMS"] ; return map }if ("WARRANT".equals(MODULE_NAME)) { def map = [MODULE_HOME: "SSP-Warrant"] ; return map }Building in workspace /usr/AutomatedBuilds/SSP-AM [EnvInject] - Variables injected successfully. Archiving artifacts Promotion Log: build BapSshPromotionPublisherPlugin[delegate=BapSshPublisherPlugin[consolePrefix=SSH: ,delegate=BPInstanceConfig[publishers=[BapSshPublisher[configName=DEV BIG-IP,verbose=false,transfers=[BapSshTransfer[sourceFiles=scripts/Environments/SSPDEV/*,excludes=/_jdbc.properties,removePrefix=scripts/Environments/,remoteDirectory=,remoteDirectorySDF=false,flatten=false,cleanRemote=false,execCommand=chmod 755 SSPDEV -R cd /J2EE/CAS/deploy/ACCT SSH: Disconnecting configuration [SSP Dev Appserver] ... cd /J2EE/CAS/deploy/$MODULE_NAME |
bap: Ah! It's in a promotion. |
Bap, |
bap: The injected variables are not replaced when the promotion executes. |
It would be nice if the injected variables are also replaced like the build parameters. Not sure why this facility is given for only build parameters and not other environment variables. |
bap: All environment variables are restored - the variables that envInject provides are build variables, not environment variables. |
@bap publih-over-ssh has to be aware of EnvInject with the following code.
|
bap: @Gbois |
Greg and Bap, |
bap: IMO this is a fundamental design problem Without EnvInject, the build environment can be accessed directly. If someone installs EnvInject then it "hijacks" the environment variables and moves them to its own action - they are no longer available directly from the build object. This requires every plugin to code for the existence of an optional plugin if it wants to be able to access the environment variables that the EnvInject plugin has moved. @Gbois is there some method in core that can be called to access the variables that EnvInject would contribute to so that this dependency can be broken? |
Kind-of related issue: https://issues.jenkins-ci.org/browse/JENKINS-14340. |
bap: @chanti I have no idea what you mean by "natural" environment variables Your output example looks like it is entirely to do with recursive resolution (JENKINS-14340) and I can't see the connection with this issue which is to do with the EnvInject plugin. |
@bap by "natural", i meant standard behaviour of vanilla jenkins. i would have expected the publish-over-ssh plugin to replicate that behaviour. i am surprised that an extra token plugin might be needed for that purpose. |
I am trying to use Jenkins environment variables and variables injected through Env Inject plugin in Execute section of 'Send build artifacts over SSH'. It does not recognize them. It does recognize the build parameters and replaces them with the values. When I look at the 'Injected environment variables' I see all the variables I want to use. Not sure if I have to do anything different to be able to use those variables.
In Job configuration I checked 'Prepare an environment for the run' and 'Keep Jenkins Environment Variables', 'Keep Jenkins Build Variables'.
I have an 'Evaluated Groovy script' that sets 'MODULE_HOME' based on build time parameter MODULE_NAME.
Please let me know how to proceed.
Originally reported by skumar, imported from: Not able to use Jenkins Environment Variables and variables injected through Env Inject plugin when executing commands over ssh in Publish over SSH plugin
The text was updated successfully, but these errors were encountered: