Skip to content

Commit

Permalink
fix(core/pipeline): When a pipeline or jenkins parameter is no longer…
Browse files Browse the repository at this point in the history
… accepted by the job/pipeline, show the parameter value (in addition to the name) in the warning message. (#7149)
  • Loading branch information
christopherthielen authored and anotherchrisberry committed Jun 27, 2019
1 parent 8d929f0 commit 973bd5c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,16 @@ <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 ng-if="hasInvalidParameters()" 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>
<div ng-repeat="(paramName, paramValue) in invalidParameters" class="flex-container-h" style="margin: 0.5em">
<label class="col-md-2">{{paramName}}</label>
<input class="flex-grow" type="text" style="width: 100%" disabled value="{{paramValue}}" />
</div>
<button class="self-right passive" ng-click="jenkinsStageCtrl.removeInvalidParameters()">Remove all</button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Registry } from 'core/registry';

import { IgorService, BuildServiceType } from 'core/ci/igor.service';
import { JenkinsExecutionLabel } from './JenkinsExecutionLabel';
import { pickBy } from 'lodash';

const angular = require('angular');

Expand Down Expand Up @@ -118,8 +119,9 @@ module.exports = angular

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

Expand All @@ -133,6 +135,7 @@ module.exports = angular
}
}

$scope.hasInvalidParameters = () => Object.keys($scope.invalidParameters || {}).length;
$scope.useDefaultParameters = {};
$scope.userSuppliedParameters = {};

Expand All @@ -146,12 +149,12 @@ module.exports = angular
};

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

initializeMasters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,16 @@ <h4 class="text-left">Pipeline Parameters</h4>
</label>
</div>
</div>
<div ng-if="invalidParameters.length" class="horizontal center sp-margin-l-top" style="width: 100%">
<div ng-if="hasInvalidParameters()" 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 pipeline but are still set in the stage configuration:
</p>
<ul>
<li ng-repeat="paramName in invalidParameters">
{{paramName}}
</li>
</ul>
<div ng-repeat="(paramName, paramValue) in invalidParameters" class="flex-container-h" style="margin: 0.5em">
<label class="col-md-2">{{paramName}}</label>
<input class="flex-grow" type="text" style="width: 100%" disabled value="{{paramValue}}" />
</div>
<button class="self-right passive" ng-click="pipelineStageCtrl.removeInvalidParameters()">Remove all</button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

import { pickBy } from 'lodash';

const angular = require('angular');

import { ApplicationReader } from 'core/application/service/ApplicationReader';
Expand Down Expand Up @@ -106,11 +108,13 @@ module.exports = angular

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

$scope.hasInvalidParameters = () => Object.keys($scope.invalidParameters || {}).length;
$scope.useDefaultParameters = {};
_.each($scope.pipelineParameters, function(property) {
if (!(property.name in $scope.stage.pipelineParameters) && property.default !== null) {
Expand Down Expand Up @@ -144,7 +148,7 @@ module.exports = angular
};

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

0 comments on commit 973bd5c

Please sign in to comment.