[JIRA] (JENKINS-13466) Custom environment variables not available when build started by an SCM change

2012-05-18 Thread gregory.boissi...@gmail.com (JIRA)

 [ 
https://issues.jenkins-ci.org/browse/JENKINS-13466?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gregory Boissinot closed JENKINS-13466.
---

Resolution: Postponed

 Custom environment variables not available when build started by an SCM change
 --

 Key: JENKINS-13466
 URL: https://issues.jenkins-ci.org/browse/JENKINS-13466
 Project: Jenkins
  Issue Type: Bug
  Components: core, envinject
 Environment: not applicable
Reporter: Robin Jarry
Assignee: Gregory Boissinot
 Attachments: custom-env-master.jpg, custom-env-slave.jpg


 Hi there,
 I may have found a sneaky bug. Custom environment variables can be defined by 
 the user into the general  nodes config:
 !custom-env-master.jpg!
 !custom-env-slave.jpg!
 When a build is triggered by an SCM change, those variables are not available 
 for SCM plugins. 
 Let's say that I have a field in my SCM plugin configured with this value: 
 *$\{JOB_NAME\}\_$\{HOSTNAME}\_$\{NODE_TYPE\}* If the build is triggered by an 
 SCM change I get this error:
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 cleartool error: Illegal characters found in view name : ${NODE_TYPE}. An 
 environment variable may have not been resolved.
 Finished: FAILURE
 {code}
 Here is the code snipet from my plugin that does that:
 {code:Java}
 @Override
 public boolean checkout(AbstractBuild build, Launcher launcher, FilePath 
 workspace, 
 BuildListener listener, File changelogFile) throws IOException, 
 InterruptedException
 {
 try {  
 logger.log(### Begin source code retrieval ###);
 String resolvedViewName = 
 build.getEnvironment(listener).expand(this.viewName);
 
 Pattern pattern = Pattern.compile((\\$\\{.+?\\}));
 Matcher matcher = pattern.matcher(resolvedViewName);
 if (matcher.find()) {
 String message = Illegal characters found in view name : %s.  +
 An environment variable may have not been resolved.;
 throw new ClearToolError(String.format(message, matcher.group()));
 }
 {code}
 I removed *$\{NODE_TYPE\}* from my SCM configuration to let the build 
 continue. And the user custom environment variables seem to be injected into 
 the build environment after the SCM checkout. 
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 ...
 [ClearCase] === End source code retrieval ===
 [polling_linux] $ /bin/sh -xe /tmp/hudson7589128551511062241.sh
 + env
 ...
 NODE_TYPE=SLAVE
 ...
 {code}
 Could this be fixed? :)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[JIRA] (JENKINS-13466) Custom environment variables not available when build started by an SCM change

2012-05-04 Thread gb...@java.net (JIRA)

[ 
https://issues.jenkins-ci.org/browse/JENKINS-13466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=161991#comment-161991
 ] 

gbois edited comment on JENKINS-13466 at 5/4/12 10:21 PM:
--

Any suggestions?

  was (Author: gbois):
Can I fix it?
  
 Custom environment variables not available when build started by an SCM change
 --

 Key: JENKINS-13466
 URL: https://issues.jenkins-ci.org/browse/JENKINS-13466
 Project: Jenkins
  Issue Type: Bug
  Components: core, envinject
 Environment: not applicable
Reporter: Robin Jarry
Assignee: gbois
 Attachments: custom-env-master.jpg, custom-env-slave.jpg


 Hi there,
 I may have found a sneaky bug. Custom environment variables can be defined by 
 the user into the general  nodes config:
 !custom-env-master.jpg!
 !custom-env-slave.jpg!
 When a build is triggered by an SCM change, those variables are not available 
 for SCM plugins. 
 Let's say that I have a field in my SCM plugin configured with this value: 
 *$\{JOB_NAME\}\_$\{HOSTNAME}\_$\{NODE_TYPE\}* If the build is triggered by an 
 SCM change I get this error:
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 cleartool error: Illegal characters found in view name : ${NODE_TYPE}. An 
 environment variable may have not been resolved.
 Finished: FAILURE
 {code}
 Here is the code snipet from my plugin that does that:
 {code:Java}
 @Override
 public boolean checkout(AbstractBuild build, Launcher launcher, FilePath 
 workspace, 
 BuildListener listener, File changelogFile) throws IOException, 
 InterruptedException
 {
 try {  
 logger.log(### Begin source code retrieval ###);
 String resolvedViewName = 
 build.getEnvironment(listener).expand(this.viewName);
 
 Pattern pattern = Pattern.compile((\\$\\{.+?\\}));
 Matcher matcher = pattern.matcher(resolvedViewName);
 if (matcher.find()) {
 String message = Illegal characters found in view name : %s.  +
 An environment variable may have not been resolved.;
 throw new ClearToolError(String.format(message, matcher.group()));
 }
 {code}
 I removed *$\{NODE_TYPE\}* from my SCM configuration to let the build 
 continue. And the user custom environment variables seem to be injected into 
 the build environment after the SCM checkout. 
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 ...
 [ClearCase] === End source code retrieval ===
 [polling_linux] $ /bin/sh -xe /tmp/hudson7589128551511062241.sh
 + env
 ...
 NODE_TYPE=SLAVE
 ...
 {code}
 Could this be fixed? :)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[JIRA] (JENKINS-13466) Custom environment variables not available when build started by an SCM change

2012-04-23 Thread gb...@java.net (JIRA)

[ 
https://issues.jenkins-ci.org/browse/JENKINS-13466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=161896#comment-161896
 ] 

gbois commented on JENKINS-13466:
-

As I said, it is an alternative solution, waiting for a Jenkins core 
refactoring.
The problem is a design Jenkins core issue.
For summary, there are two temporary solutions:
1) Install the EnvInject and use it, all environment variables will be 
populated.
2) Or depend on the envinject-lib library, modify your code to use 
EnvVarsResolver#resolveEnVars(build, this.viewName)
This latest solution enables you to not depend of the EnvInject plugin 
(installed or not, activated or not).
The only drawback is to have an additional dependency. It is due to a Jenkins 
core problem.

 Custom environment variables not available when build started by an SCM change
 --

 Key: JENKINS-13466
 URL: https://issues.jenkins-ci.org/browse/JENKINS-13466
 Project: Jenkins
  Issue Type: Bug
  Components: core, envinject
 Environment: not applicable
Reporter: Robin Jarry
Assignee: gbois
 Attachments: custom-env-master.jpg, custom-env-slave.jpg


 Hi there,
 I may have found a sneaky bug. Custom environment variables can be defined by 
 the user into the general  nodes config:
 !custom-env-master.jpg!
 !custom-env-slave.jpg!
 When a build is triggered by an SCM change, those variables are not available 
 for SCM plugins. 
 Let's say that I have a field in my SCM plugin configured with this value: 
 *$\{JOB_NAME\}\_$\{HOSTNAME}\_$\{NODE_TYPE\}* If the build is triggered by an 
 SCM change I get this error:
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 cleartool error: Illegal characters found in view name : ${NODE_TYPE}. An 
 environment variable may have not been resolved.
 Finished: FAILURE
 {code}
 Here is the code snipet from my plugin that does that:
 {code:Java}
 @Override
 public boolean checkout(AbstractBuild build, Launcher launcher, FilePath 
 workspace, 
 BuildListener listener, File changelogFile) throws IOException, 
 InterruptedException
 {
 try {  
 logger.log(### Begin source code retrieval ###);
 String resolvedViewName = 
 build.getEnvironment(listener).expand(this.viewName);
 
 Pattern pattern = Pattern.compile((\\$\\{.+?\\}));
 Matcher matcher = pattern.matcher(resolvedViewName);
 if (matcher.find()) {
 String message = Illegal characters found in view name : %s.  +
 An environment variable may have not been resolved.;
 throw new ClearToolError(String.format(message, matcher.group()));
 }
 {code}
 I removed *$\{NODE_TYPE\}* from my SCM configuration to let the build 
 continue. And the user custom environment variables seem to be injected into 
 the build environment after the SCM checkout. 
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 ...
 [ClearCase] === End source code retrieval ===
 [polling_linux] $ /bin/sh -xe /tmp/hudson7589128551511062241.sh
 + env
 ...
 NODE_TYPE=SLAVE
 ...
 {code}
 Could this be fixed? :)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[JIRA] (JENKINS-13466) Custom environment variables not available when build started by an SCM change

2012-04-21 Thread gb...@java.net (JIRA)

[ 
https://issues.jenkins-ci.org/browse/JENKINS-13466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=161873#comment-161873
 ] 

gbois commented on JENKINS-13466:
-

Additionally, if you just install the envinject-plugin and active it, it has to 
work. 

 Custom environment variables not available when build started by an SCM change
 --

 Key: JENKINS-13466
 URL: https://issues.jenkins-ci.org/browse/JENKINS-13466
 Project: Jenkins
  Issue Type: Bug
  Components: core, envinject
 Environment: not applicable
Reporter: Robin Jarry
Assignee: gbois
 Attachments: custom-env-master.jpg, custom-env-slave.jpg


 Hi there,
 I may have found a sneaky bug. Custom environment variables can be defined by 
 the user into the general  nodes config:
 !custom-env-master.jpg!
 !custom-env-slave.jpg!
 When a build is triggered by an SCM change, those variables are not available 
 for SCM plugins. 
 Let's say that I have a field in my SCM plugin configured with this value: 
 *$\{JOB_NAME\}\_$\{HOSTNAME}\_$\{NODE_TYPE\}* If the build is triggered by an 
 SCM change I get this error:
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 cleartool error: Illegal characters found in view name : ${NODE_TYPE}. An 
 environment variable may have not been resolved.
 Finished: FAILURE
 {code}
 Here is the code snipet from my plugin that does that:
 {code:Java}
 @Override
 public boolean checkout(AbstractBuild build, Launcher launcher, FilePath 
 workspace, 
 BuildListener listener, File changelogFile) throws IOException, 
 InterruptedException
 {
 try {  
 logger.log(### Begin source code retrieval ###);
 String resolvedViewName = 
 build.getEnvironment(listener).expand(this.viewName);
 
 Pattern pattern = Pattern.compile((\\$\\{.+?\\}));
 Matcher matcher = pattern.matcher(resolvedViewName);
 if (matcher.find()) {
 String message = Illegal characters found in view name : %s.  +
 An environment variable may have not been resolved.;
 throw new ClearToolError(String.format(message, matcher.group()));
 }
 {code}
 I removed *$\{NODE_TYPE\}* from my SCM configuration to let the build 
 continue. And the user custom environment variables seem to be injected into 
 the build environment after the SCM checkout. 
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 ...
 [ClearCase] === End source code retrieval ===
 [polling_linux] $ /bin/sh -xe /tmp/hudson7589128551511062241.sh
 + env
 ...
 NODE_TYPE=SLAVE
 ...
 {code}
 Could this be fixed? :)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[JIRA] (JENKINS-13466) Custom environment variables not available when build started by an SCM change

2012-04-19 Thread gb...@java.net (JIRA)

 [ 
https://issues.jenkins-ci.org/browse/JENKINS-13466?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

gbois updated JENKINS-13466:


Labels:   (was: envinronment-variables polling)

 Custom environment variables not available when build started by an SCM change
 --

 Key: JENKINS-13466
 URL: https://issues.jenkins-ci.org/browse/JENKINS-13466
 Project: Jenkins
  Issue Type: Bug
  Components: core, envinject
 Environment: not applicable
Reporter: Robin Jarry
Assignee: Frédéric Camblor
 Attachments: custom-env-master.jpg, custom-env-slave.jpg


 Hi there,
 I may have found a sneaky bug. Custom environment variables can be defined by 
 the user into the general  nodes config:
 !custom-env-master.jpg!
 !custom-env-slave.jpg!
 When a build is triggered by an SCM change, those variables are not available 
 for SCM plugins. 
 Let's say that I have a field in my SCM plugin configured with this value: 
 *$\{JOB_NAME\}\_$\{HOSTNAME}\_$\{NODE_TYPE\}* If the build is triggered by an 
 SCM change I get this error:
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 cleartool error: Illegal characters found in view name : ${NODE_TYPE}. An 
 environment variable may have not been resolved.
 Finished: FAILURE
 {code}
 Here is the code snipet from my plugin that does that:
 {code:Java}
 @Override
 public boolean checkout(AbstractBuild build, Launcher launcher, FilePath 
 workspace, 
 BuildListener listener, File changelogFile) throws IOException, 
 InterruptedException
 {
 try {  
 logger.log(### Begin source code retrieval ###);
 String resolvedViewName = 
 build.getEnvironment(listener).expand(this.viewName);
 
 Pattern pattern = Pattern.compile((\\$\\{.+?\\}));
 Matcher matcher = pattern.matcher(resolvedViewName);
 if (matcher.find()) {
 String message = Illegal characters found in view name : %s.  +
 An environment variable may have not been resolved.;
 throw new ClearToolError(String.format(message, matcher.group()));
 }
 {code}
 I removed *$\{NODE_TYPE\}* from my SCM configuration to let the build 
 continue. And the user custom environment variables seem to be injected into 
 the build environment after the SCM checkout. 
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 ...
 [ClearCase] === End source code retrieval ===
 [polling_linux] $ /bin/sh -xe /tmp/hudson7589128551511062241.sh
 + env
 ...
 NODE_TYPE=SLAVE
 ...
 {code}
 Could this be fixed? :)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[JIRA] (JENKINS-13466) Custom environment variables not available when build started by an SCM change

2012-04-19 Thread gb...@java.net (JIRA)

 [ 
https://issues.jenkins-ci.org/browse/JENKINS-13466?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

gbois updated JENKINS-13466:


   Assignee: gbois  (was: Frédéric Camblor)
Component/s: core
 envinject
 (was: scm-sync-configuration)

 Custom environment variables not available when build started by an SCM change
 --

 Key: JENKINS-13466
 URL: https://issues.jenkins-ci.org/browse/JENKINS-13466
 Project: Jenkins
  Issue Type: Bug
  Components: core, envinject
 Environment: not applicable
Reporter: Robin Jarry
Assignee: gbois
 Attachments: custom-env-master.jpg, custom-env-slave.jpg


 Hi there,
 I may have found a sneaky bug. Custom environment variables can be defined by 
 the user into the general  nodes config:
 !custom-env-master.jpg!
 !custom-env-slave.jpg!
 When a build is triggered by an SCM change, those variables are not available 
 for SCM plugins. 
 Let's say that I have a field in my SCM plugin configured with this value: 
 *$\{JOB_NAME\}\_$\{HOSTNAME}\_$\{NODE_TYPE\}* If the build is triggered by an 
 SCM change I get this error:
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 cleartool error: Illegal characters found in view name : ${NODE_TYPE}. An 
 environment variable may have not been resolved.
 Finished: FAILURE
 {code}
 Here is the code snipet from my plugin that does that:
 {code:Java}
 @Override
 public boolean checkout(AbstractBuild build, Launcher launcher, FilePath 
 workspace, 
 BuildListener listener, File changelogFile) throws IOException, 
 InterruptedException
 {
 try {  
 logger.log(### Begin source code retrieval ###);
 String resolvedViewName = 
 build.getEnvironment(listener).expand(this.viewName);
 
 Pattern pattern = Pattern.compile((\\$\\{.+?\\}));
 Matcher matcher = pattern.matcher(resolvedViewName);
 if (matcher.find()) {
 String message = Illegal characters found in view name : %s.  +
 An environment variable may have not been resolved.;
 throw new ClearToolError(String.format(message, matcher.group()));
 }
 {code}
 I removed *$\{NODE_TYPE\}* from my SCM configuration to let the build 
 continue. And the user custom environment variables seem to be injected into 
 the build environment after the SCM checkout. 
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 ...
 [ClearCase] === End source code retrieval ===
 [polling_linux] $ /bin/sh -xe /tmp/hudson7589128551511062241.sh
 + env
 ...
 NODE_TYPE=SLAVE
 ...
 {code}
 Could this be fixed? :)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[JIRA] (JENKINS-13466) Custom environment variables not available when build started by an SCM change

2012-04-19 Thread scm_issue_l...@java.net (JIRA)

[ 
https://issues.jenkins-ci.org/browse/JENKINS-13466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=161801#comment-161801
 ] 

SCM/JIRA link daemon commented on JENKINS-13466:


Code changed in jenkins
User: Gregory Boissinot
Path:
 src/main/java/org/jenkinsci/lib/envinject/service/EnvVarsResolver.java
http://jenkins-ci.org/commit/envinject-lib/dfd27a41e20b9694c50511d001c1b171f477946e
Log:
  Add support of JENKINS-13466






 Custom environment variables not available when build started by an SCM change
 --

 Key: JENKINS-13466
 URL: https://issues.jenkins-ci.org/browse/JENKINS-13466
 Project: Jenkins
  Issue Type: Bug
  Components: core, envinject
 Environment: not applicable
Reporter: Robin Jarry
Assignee: gbois
 Attachments: custom-env-master.jpg, custom-env-slave.jpg


 Hi there,
 I may have found a sneaky bug. Custom environment variables can be defined by 
 the user into the general  nodes config:
 !custom-env-master.jpg!
 !custom-env-slave.jpg!
 When a build is triggered by an SCM change, those variables are not available 
 for SCM plugins. 
 Let's say that I have a field in my SCM plugin configured with this value: 
 *$\{JOB_NAME\}\_$\{HOSTNAME}\_$\{NODE_TYPE\}* If the build is triggered by an 
 SCM change I get this error:
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 cleartool error: Illegal characters found in view name : ${NODE_TYPE}. An 
 environment variable may have not been resolved.
 Finished: FAILURE
 {code}
 Here is the code snipet from my plugin that does that:
 {code:Java}
 @Override
 public boolean checkout(AbstractBuild build, Launcher launcher, FilePath 
 workspace, 
 BuildListener listener, File changelogFile) throws IOException, 
 InterruptedException
 {
 try {  
 logger.log(### Begin source code retrieval ###);
 String resolvedViewName = 
 build.getEnvironment(listener).expand(this.viewName);
 
 Pattern pattern = Pattern.compile((\\$\\{.+?\\}));
 Matcher matcher = pattern.matcher(resolvedViewName);
 if (matcher.find()) {
 String message = Illegal characters found in view name : %s.  +
 An environment variable may have not been resolved.;
 throw new ClearToolError(String.format(message, matcher.group()));
 }
 {code}
 I removed *$\{NODE_TYPE\}* from my SCM configuration to let the build 
 continue. And the user custom environment variables seem to be injected into 
 the build environment after the SCM checkout. 
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 ...
 [ClearCase] === End source code retrieval ===
 [polling_linux] $ /bin/sh -xe /tmp/hudson7589128551511062241.sh
 + env
 ...
 NODE_TYPE=SLAVE
 ...
 {code}
 Could this be fixed? :)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[JIRA] (JENKINS-13466) Custom environment variables not available when build started by an SCM change

2012-04-19 Thread gb...@java.net (JIRA)

[ 
https://issues.jenkins-ci.org/browse/JENKINS-13466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=161802#comment-161802
 ] 

gbois commented on JENKINS-13466:
-

The issue is not a bug but a design issue.
EnvironmentVariablesNodeProperty variables are computed at the launcher 
creation and it is not possible to compute them in another way.

At the moment, my proposal solution is to add a dependency to envinject-lib and 
use
EnvVarsResolver#resolveEnVars(build, this.viewName)

This method uses the variables injected by the EnvInject plugin if it is 
installed. If the plugin is not installed, all environment variables are 
computed (and EnvironmentVariablesNodeProperty are used).

The only incovenience is to tie your code with this library.
Hopefully, this solution should be suitable for you.

 Custom environment variables not available when build started by an SCM change
 --

 Key: JENKINS-13466
 URL: https://issues.jenkins-ci.org/browse/JENKINS-13466
 Project: Jenkins
  Issue Type: Bug
  Components: core, envinject
 Environment: not applicable
Reporter: Robin Jarry
Assignee: gbois
 Attachments: custom-env-master.jpg, custom-env-slave.jpg


 Hi there,
 I may have found a sneaky bug. Custom environment variables can be defined by 
 the user into the general  nodes config:
 !custom-env-master.jpg!
 !custom-env-slave.jpg!
 When a build is triggered by an SCM change, those variables are not available 
 for SCM plugins. 
 Let's say that I have a field in my SCM plugin configured with this value: 
 *$\{JOB_NAME\}\_$\{HOSTNAME}\_$\{NODE_TYPE\}* If the build is triggered by an 
 SCM change I get this error:
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 cleartool error: Illegal characters found in view name : ${NODE_TYPE}. An 
 environment variable may have not been resolved.
 Finished: FAILURE
 {code}
 Here is the code snipet from my plugin that does that:
 {code:Java}
 @Override
 public boolean checkout(AbstractBuild build, Launcher launcher, FilePath 
 workspace, 
 BuildListener listener, File changelogFile) throws IOException, 
 InterruptedException
 {
 try {  
 logger.log(### Begin source code retrieval ###);
 String resolvedViewName = 
 build.getEnvironment(listener).expand(this.viewName);
 
 Pattern pattern = Pattern.compile((\\$\\{.+?\\}));
 Matcher matcher = pattern.matcher(resolvedViewName);
 if (matcher.find()) {
 String message = Illegal characters found in view name : %s.  +
 An environment variable may have not been resolved.;
 throw new ClearToolError(String.format(message, matcher.group()));
 }
 {code}
 I removed *$\{NODE_TYPE\}* from my SCM configuration to let the build 
 continue. And the user custom environment variables seem to be injected into 
 the build environment after the SCM checkout. 
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 ...
 [ClearCase] === End source code retrieval ===
 [polling_linux] $ /bin/sh -xe /tmp/hudson7589128551511062241.sh
 + env
 ...
 NODE_TYPE=SLAVE
 ...
 {code}
 Could this be fixed? :)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[JIRA] (JENKINS-13466) Custom environment variables not available when build started by an SCM change

2012-04-16 Thread robin.ja...@gmail.com (JIRA)
Robin Jarry created JENKINS-13466:
-

 Summary: Custom environment variables not available when build 
started by an SCM change
 Key: JENKINS-13466
 URL: https://issues.jenkins-ci.org/browse/JENKINS-13466
 Project: Jenkins
  Issue Type: Bug
  Components: scm-sync-configuration
 Environment: not applicable
Reporter: Robin Jarry
Assignee: Frédéric Camblor
 Attachments: custom-env-master.jpg, custom-env-slave.jpg

Hi there,

I may have found a sneaky bug. Custom environment variables can be defined by 
the user into the general  nodes config:

!custom-env-master.jpg!

!custom-env-slave.jpg!

When a build is triggered by an SCM change, those variables are not available 
for SCM plugins. 

Let's say that I have a field in my SCM plugin configured with this value: 
*$\{JOB_NAME\}_$\{HOSTNAME}_$\{NODE_TYPE\}* If the build is triggered by an SCM 
change I get this error:

{code}
Started by an SCM change
Building remotely on vmo426
[ClearCase] ### Begin source code retrieval ###
cleartool error: Illegal characters found in view name : ${NODE_TYPE}. An 
environment variable may have not been resolved.
Finished: FAILURE
{code}

Here is the code snipet from my plugin that does that:

{code:Java}
@Override
public boolean checkout(AbstractBuild build, Launcher launcher, FilePath 
workspace, 
BuildListener listener, File changelogFile) throws IOException, 
InterruptedException
{
try {  
logger.log(### Begin source code retrieval ###);

String resolvedViewName = 
build.getEnvironment(listener).expand(this.viewName);

Pattern pattern = Pattern.compile((\\$\\{.+?\\}));
Matcher matcher = pattern.matcher(resolvedViewName);
if (matcher.find()) {
String message = Illegal characters found in view name : %s.  +
An environment variable may have not been resolved.;
throw new ClearToolError(String.format(message, matcher.group()));
}
{code}

I removed *$\{NODE_TYPE\}* from my SCM configuration to let the build continue. 
And the user custom environment variables seem to be injected into the build 
environment after the SCM checkout. 

{code}
Started by an SCM change
Building remotely on vmo426
[ClearCase] ### Begin source code retrieval ###
...
[ClearCase] === End source code retrieval ===
[polling_linux] $ /bin/sh -xe /tmp/hudson7589128551511062241.sh
+ env
...
NODE_TYPE=SLAVE
...
{code}

Could this be fixed? :)


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[JIRA] (JENKINS-13466) Custom environment variables not available when build started by an SCM change

2012-04-16 Thread robin.ja...@gmail.com (JIRA)

 [ 
https://issues.jenkins-ci.org/browse/JENKINS-13466?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Robin Jarry updated JENKINS-13466:
--

Description: 
Hi there,

I may have found a sneaky bug. Custom environment variables can be defined by 
the user into the general  nodes config:

!custom-env-master.jpg!

!custom-env-slave.jpg!

When a build is triggered by an SCM change, those variables are not available 
for SCM plugins. 

Let's say that I have a field in my SCM plugin configured with this value: 
*$\{JOB_NAME\}\_$\{HOSTNAME}\_$\{NODE_TYPE\}* If the build is triggered by an 
SCM change I get this error:

{code}
Started by an SCM change
Building remotely on vmo426
[ClearCase] ### Begin source code retrieval ###
cleartool error: Illegal characters found in view name : ${NODE_TYPE}. An 
environment variable may have not been resolved.
Finished: FAILURE
{code}

Here is the code snipet from my plugin that does that:

{code:Java}
@Override
public boolean checkout(AbstractBuild build, Launcher launcher, FilePath 
workspace, 
BuildListener listener, File changelogFile) throws IOException, 
InterruptedException
{
try {  
logger.log(### Begin source code retrieval ###);

String resolvedViewName = 
build.getEnvironment(listener).expand(this.viewName);

Pattern pattern = Pattern.compile((\\$\\{.+?\\}));
Matcher matcher = pattern.matcher(resolvedViewName);
if (matcher.find()) {
String message = Illegal characters found in view name : %s.  +
An environment variable may have not been resolved.;
throw new ClearToolError(String.format(message, matcher.group()));
}
{code}

I removed *$\{NODE_TYPE\}* from my SCM configuration to let the build continue. 
And the user custom environment variables seem to be injected into the build 
environment after the SCM checkout. 

{code}
Started by an SCM change
Building remotely on vmo426
[ClearCase] ### Begin source code retrieval ###
...
[ClearCase] === End source code retrieval ===
[polling_linux] $ /bin/sh -xe /tmp/hudson7589128551511062241.sh
+ env
...
NODE_TYPE=SLAVE
...
{code}

Could this be fixed? :)


  was:
Hi there,

I may have found a sneaky bug. Custom environment variables can be defined by 
the user into the general  nodes config:

!custom-env-master.jpg!

!custom-env-slave.jpg!

When a build is triggered by an SCM change, those variables are not available 
for SCM plugins. 

Let's say that I have a field in my SCM plugin configured with this value: 
*$\{JOB_NAME\}_$\{HOSTNAME}_$\{NODE_TYPE\}* If the build is triggered by an SCM 
change I get this error:

{code}
Started by an SCM change
Building remotely on vmo426
[ClearCase] ### Begin source code retrieval ###
cleartool error: Illegal characters found in view name : ${NODE_TYPE}. An 
environment variable may have not been resolved.
Finished: FAILURE
{code}

Here is the code snipet from my plugin that does that:

{code:Java}
@Override
public boolean checkout(AbstractBuild build, Launcher launcher, FilePath 
workspace, 
BuildListener listener, File changelogFile) throws IOException, 
InterruptedException
{
try {  
logger.log(### Begin source code retrieval ###);

String resolvedViewName = 
build.getEnvironment(listener).expand(this.viewName);

Pattern pattern = Pattern.compile((\\$\\{.+?\\}));
Matcher matcher = pattern.matcher(resolvedViewName);
if (matcher.find()) {
String message = Illegal characters found in view name : %s.  +
An environment variable may have not been resolved.;
throw new ClearToolError(String.format(message, matcher.group()));
}
{code}

I removed *$\{NODE_TYPE\}* from my SCM configuration to let the build continue. 
And the user custom environment variables seem to be injected into the build 
environment after the SCM checkout. 

{code}
Started by an SCM change
Building remotely on vmo426
[ClearCase] ### Begin source code retrieval ###
...
[ClearCase] === End source code retrieval ===
[polling_linux] $ /bin/sh -xe /tmp/hudson7589128551511062241.sh
+ env
...
NODE_TYPE=SLAVE
...
{code}

Could this be fixed? :)



 Custom environment variables not available when build started by an SCM change
 --

 Key: JENKINS-13466
 URL: https://issues.jenkins-ci.org/browse/JENKINS-13466
 Project: Jenkins
  Issue Type: Bug
  Components: scm-sync-configuration
 Environment: not applicable
Reporter: Robin Jarry
Assignee: Frédéric Camblor
  Labels: envinronment-variables, polling
 Attachments: custom-env-master.jpg, custom-env-slave.jpg


 Hi there,
 I may have found a sneaky bug. Custom environment variables can be defined by 
 

[JIRA] (JENKINS-13466) Custom environment variables not available when build started by an SCM change

2012-04-16 Thread gb...@java.net (JIRA)

[ 
https://issues.jenkins-ci.org/browse/JENKINS-13466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=161648#comment-161648
 ] 

gbois commented on JENKINS-13466:
-

I think environment variables defined in node properties are not available in 
AbstractBuild.getEnvironment(TaskListener) method.
I think it doesn't work in your use case because you have maybe created your 
own launcher.
Therefore, the following code is not available

for (NodeProperty nodeProperty: 
Hudson.getInstance().getGlobalNodeProperties()) {
Environment environment = 
nodeProperty.setUp(AbstractBuild.this, l, listener);
if (environment != null) {
buildEnvironments.add(environment);
}
}

for (NodeProperty nodeProperty: 
Computer.currentComputer().getNode().getNodeProperties()) {
Environment environment = 
nodeProperty.setUp(AbstractBuild.this, l, listener);
if (environment != null) {
buildEnvironments.add(environment);
}
}


located in AbstractBuild#createLauncher() method

A better alternative is to use the great EnvInject plugin :)
With it, in your SCM code, just get the EnvInjectAction and its captured 
environment variables (used in my forked SCM clearcase plugin).


 Custom environment variables not available when build started by an SCM change
 --

 Key: JENKINS-13466
 URL: https://issues.jenkins-ci.org/browse/JENKINS-13466
 Project: Jenkins
  Issue Type: Bug
  Components: scm-sync-configuration
 Environment: not applicable
Reporter: Robin Jarry
Assignee: Frédéric Camblor
  Labels: envinronment-variables, polling
 Attachments: custom-env-master.jpg, custom-env-slave.jpg


 Hi there,
 I may have found a sneaky bug. Custom environment variables can be defined by 
 the user into the general  nodes config:
 !custom-env-master.jpg!
 !custom-env-slave.jpg!
 When a build is triggered by an SCM change, those variables are not available 
 for SCM plugins. 
 Let's say that I have a field in my SCM plugin configured with this value: 
 *$\{JOB_NAME\}\_$\{HOSTNAME}\_$\{NODE_TYPE\}* If the build is triggered by an 
 SCM change I get this error:
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 cleartool error: Illegal characters found in view name : ${NODE_TYPE}. An 
 environment variable may have not been resolved.
 Finished: FAILURE
 {code}
 Here is the code snipet from my plugin that does that:
 {code:Java}
 @Override
 public boolean checkout(AbstractBuild build, Launcher launcher, FilePath 
 workspace, 
 BuildListener listener, File changelogFile) throws IOException, 
 InterruptedException
 {
 try {  
 logger.log(### Begin source code retrieval ###);
 String resolvedViewName = 
 build.getEnvironment(listener).expand(this.viewName);
 
 Pattern pattern = Pattern.compile((\\$\\{.+?\\}));
 Matcher matcher = pattern.matcher(resolvedViewName);
 if (matcher.find()) {
 String message = Illegal characters found in view name : %s.  +
 An environment variable may have not been resolved.;
 throw new ClearToolError(String.format(message, matcher.group()));
 }
 {code}
 I removed *$\{NODE_TYPE\}* from my SCM configuration to let the build 
 continue. And the user custom environment variables seem to be injected into 
 the build environment after the SCM checkout. 
 {code}
 Started by an SCM change
 Building remotely on vmo426
 [ClearCase] ### Begin source code retrieval ###
 ...
 [ClearCase] === End source code retrieval ===
 [polling_linux] $ /bin/sh -xe /tmp/hudson7589128551511062241.sh
 + env
 ...
 NODE_TYPE=SLAVE
 ...
 {code}
 Could this be fixed? :)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira