Skip to content

Commit

Permalink
Fix NPE for non-parametrized job and wrong url of repository.
Browse files Browse the repository at this point in the history
  • Loading branch information
lvotypko committed Aug 3, 2012
1 parent 910b6a1 commit a676f72
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -24,13 +24,13 @@
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://maven.jenkins-ci.org/content/groups/artifacts/</url>
<url>http://maven.jenkins-ci.org:8081/content/repositories/releases/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://maven.jenkins-ci.org/content/groups/artifacts/</url>
<url>http://maven.jenkins-ci.org:8081/content/repositories/releases/</url>
</pluginRepository>
</pluginRepositories>
<properties>
Expand Down
Expand Up @@ -92,12 +92,17 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
// expand the parameters before passing these to the execution, this is to allow any token macro to resolve parameter values
List<Parameter> expandedParams = new LinkedList<Parameter>();

final ParametersAction paramsAction = build.getAction(ParametersAction.class);
final List<ParameterValue> jobParams = paramsAction.getParameters();
if (propagateParams) {
for (ParameterValue parameterValue : jobParams) {
// pass the params to the token expander in a way that these get expanded by environment variables (params are also environment variables)
expandedParams.add(new Parameter(parameterValue.getName(), TokenMacro.expandAll(build, listener, "${" + parameterValue.getName() + "}")));
final ParametersAction paramsAction = build.getAction(ParametersAction.class);
if(paramsAction==null){
listener.getLogger().println(Messages.no_parameters_defined());
}
else{
final List<ParameterValue> jobParams = paramsAction.getParameters();
for (ParameterValue parameterValue : jobParams) {
// pass the params to the token expander in a way that these get expanded by environment variables (params are also environment variables)
expandedParams.add(new Parameter(parameterValue.getName(), TokenMacro.expandAll(build, listener, "${" + parameterValue.getName() + "}")));
}
}
}
for (Parameter parameter : parameters) {
Expand All @@ -111,6 +116,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
}
} catch (Exception e) {
listener.getLogger().print(Messages.scriptExecutionFailed(scriptId) + " - " + e.getMessage());
e.printStackTrace(listener.getLogger());
}
} else {
if (StringUtils.isBlank(scriptId)) {
Expand Down
Expand Up @@ -36,4 +36,5 @@ scriptExecutionFailed = Execution of script [{0}] failed
parameterExtractionFailed = failed to read parameters from request
scriptSourceNotFound = not able to load sources for script [{0}]
skipParamter = skipping parameter [{0}] this name is used internal, please rename!"
resultPrefix = Result:
resultPrefix = Result:
no_parameters_defined = There is not any parameter defined for this job.

0 comments on commit a676f72

Please sign in to comment.