Skip to content
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

Build param definitions #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/Jenkins/Build.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,20 @@ public function getInputParameters()
{
$parameters = array();

if (!property_exists($this->build->actions[0], 'parameters')) {
return $parameters;
}

foreach ($this->build->actions[0]->parameters as $parameter) {
$parameters[$parameter->name] = $parameter->value;
}
// Parameters may not always be the first definition. Search for 'hudson.model.ParametersAction' to find
// real parameters.
foreach ($this->build->actions as $action) {
if (isset($action->_class) && $action->_class === 'hudson.model.ParametersAction') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this condition ? With this one, I can't retrieve any parameters from my build (on jenkins 1.656)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we don't have tools to automatically check code style, but can you replace your tabs by 4 spaces as we follow psr2/3 (cf https://github.com/jenkins-khan/jenkins-php-api#coding-standards)

if (!property_exists($action, 'parameters')) {
return $parameters;
}

foreach ($action->parameters as $parameter) {
$parameters[$parameter->name] = $parameter->value;
}
return $parameters;
}
}

return $parameters;
}
Expand Down