Skip to content

Commit

Permalink
feat(core): Warning message about invalid job params (#6669)
Browse files Browse the repository at this point in the history
  • Loading branch information
archana-s authored and anotherchrisberry committed Mar 12, 2019
1 parent a28f7af commit eacfe75
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,20 @@ <h4 class="text-left">Job Parameters</h4>
</label>
</div>
</div>
<div ng-if="invalidParameters.length" class="horizontal center sp-margin-l-top" style="width: 100%">
<div class="alert alert-danger vertical">
<p>
<i class="fa fa-exclamation-triangle"></i>
The following parameters are not accepted by the jenkins job but are still set in the stage configuration:
</p>
<ul>
<li ng-repeat="paramName in invalidParameters">
{{paramName}}
</li>
</ul>
<button class="self-right passive" ng-click="jenkinsStageCtrl.removeInvalidParameters()">Remove all</button>
</div>
</div>
</div>

<stage-config-field label="Wait for results" help-key="jenkins.waitForCompletion">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ module.exports = angular
function updateJobConfig() {
let stage = $scope.stage,
view = $scope.viewState;

if (stage && stage.master && stage.job && !view.masterIsParameterized && !view.jobIsParameterized) {
IgorService.getJobConfig($scope.stage.master, $scope.stage.job).then(config => {
config = config || {};
Expand All @@ -114,6 +115,14 @@ module.exports = angular
$scope.jobParams = config.parameterDefinitionList;
$scope.userSuppliedParameters = $scope.stage.parameters;
$scope.useDefaultParameters = {};

if ($scope.jobParams) {
const acceptedJobParameters = $scope.jobParams.map(param => param.name);
$scope.invalidParameters = Object.keys($scope.userSuppliedParameters).filter(
paramName => !acceptedJobParameters.includes(paramName),
);
}

let params = $scope.jobParams || [];
params.forEach(property => {
if (!(property.name in $scope.stage.parameters) && property.defaultValue !== null) {
Expand All @@ -136,6 +145,15 @@ module.exports = angular
}
};

this.removeInvalidParameters = function() {
$scope.invalidParameters.forEach(param => {
if ($scope.stage.parameters[param] !== 'undefined') {
delete $scope.stage.parameters[param];
}
});
$scope.invalidParameters = [];
};

initializeMasters();

$scope.$watch('stage.master', updateJobsList);
Expand Down

0 comments on commit eacfe75

Please sign in to comment.