diff --git a/app/index.html b/app/index.html index d48c845b7b..0c2bb77c91 100644 --- a/app/index.html +++ b/app/index.html @@ -140,6 +140,7 @@

JavaScript Required

+ diff --git a/app/scripts/constants.js b/app/scripts/constants.js index 72ac1dbb56..5624ff7df1 100644 --- a/app/scripts/constants.js +++ b/app/scripts/constants.js @@ -51,6 +51,7 @@ window.OPENSHIFT_CONSTANTS = { "builds": "architecture/core_concepts/builds_and_image_streams.html#builds", "image-streams": "architecture/core_concepts/builds_and_image_streams.html#image-streams", "storage": "architecture/additional_concepts/storage.html", + "build-hooks": "dev_guide/builds.html#build-hooks", // default should remain last, add new links above "default": "welcome/index.html" }, diff --git a/app/scripts/controllers/edit/buildConfig.js b/app/scripts/controllers/edit/buildConfig.js index 65ee16601d..ffd3d0b2c6 100644 --- a/app/scripts/controllers/edit/buildConfig.js +++ b/app/scripts/controllers/edit/buildConfig.js @@ -55,7 +55,8 @@ angular.module('openshiftConsole') "title": "Inline" }]; $scope.view = { - advancedOptions: false + advancedOptions: false, + hasHooks: false }; $scope.breadcrumbs = [ { @@ -117,6 +118,79 @@ angular.module('openshiftConsole') "SerialLatestOnly" ]; + $scope.buildHookTypes = [{ + id: "command", + label: "Command" + }, { + id: "script", + label: "Shell Script" + }, { + id: "args", + label: "Arguments to default image entry point" + }, { + id: "commandArgs", + label: "Command with arguments" + }, { + id: "scriptArgs", + label: "Shell script with arguments" + }]; + + $scope.buildHookSelection = { + type: {} + }; + + var getInitialBuildHookSelection = function() { + var hasArgs = !_.isEmpty(_.get($scope, 'buildConfig.spec.postCommit.args')); + var hasCommand = !_.isEmpty(_.get($scope, 'buildConfig.spec.postCommit.command')); + var hasScript = !!_.get($scope, 'buildConfig.spec.postCommit.script'); + $scope.view.hasHooks = hasArgs || hasCommand || hasScript; + + var id; + + if (hasArgs && hasCommand) { + id = 'commandArgs'; + } else if (hasArgs && hasScript) { + id = 'scriptArgs'; + } else if (hasArgs) { + id = 'args'; + } else if (hasScript) { + id = 'script'; + } else { + id = 'command'; + } + + $scope.buildHookSelection.type = _.find($scope.buildHookTypes, { id: id }); + }; + + var clearIncompatibleBuildHookFields = function() { + if (!$scope.view.hasHooks) { + delete $scope.updatedBuildConfig.spec.postCommit.command; + delete $scope.updatedBuildConfig.spec.postCommit.args; + delete $scope.updatedBuildConfig.spec.postCommit.script; + } else { + switch ($scope.buildHookSelection.type.id) { + case "script": + delete $scope.updatedBuildConfig.spec.postCommit.command; + delete $scope.updatedBuildConfig.spec.postCommit.args; + break; + case "command": + delete $scope.updatedBuildConfig.spec.postCommit.script; + delete $scope.updatedBuildConfig.spec.postCommit.args; + break; + case "args": + delete $scope.updatedBuildConfig.spec.postCommit.script; + delete $scope.updatedBuildConfig.spec.postCommit.command; + break; + case "scriptArgs": + delete $scope.updatedBuildConfig.spec.postCommit.command; + break; + case "commandArgs": + delete $scope.updatedBuildConfig.spec.postCommit.script; + break; + } + } + }; + AlertMessageService.getAlerts().forEach(function(alert) { $scope.alerts[alert.name] = alert.data; }); @@ -143,6 +217,8 @@ angular.module('openshiftConsole') // success function(buildConfig) { $scope.buildConfig = buildConfig; + getInitialBuildHookSelection(); + $scope.updatedBuildConfig = angular.copy($scope.buildConfig); $scope.buildStrategy = buildStrategy($scope.updatedBuildConfig); $scope.strategyType = $scope.buildConfig.spec.strategy.type; @@ -180,7 +256,7 @@ angular.module('openshiftConsole') } if (imageOptions.type === "ImageStreamImage") { - isimage = (imageData.namespace || buildConfig.metadata.namespace) + "/" + imageData.name; + isimage = (imageData.namespace || buildConfig.metadata.namespace) + "/" + imageData.name; } else { isimage = ""; } @@ -414,6 +490,7 @@ angular.module('openshiftConsole') $scope.save = function() { $scope.disableInputs = true; + clearIncompatibleBuildHookFields(); // Update Configuration buildStrategy($scope.updatedBuildConfig).forcePull = $scope.options.forcePull; diff --git a/app/scripts/directives/editCommand.js b/app/scripts/directives/editCommand.js index b30ce945f7..832fd55cf2 100644 --- a/app/scripts/directives/editCommand.js +++ b/app/scripts/directives/editCommand.js @@ -6,6 +6,7 @@ angular.module('openshiftConsole') restrict: 'E', scope: { args: '=', + type: '@', isRequired: '=' }, templateUrl: 'views/directives/_edit-command.html', diff --git a/app/views/directives/_edit-command.html b/app/views/directives/_edit-command.html index 0f47ec479c..b6eb4de56e 100644 --- a/app/views/directives/_edit-command.html +++ b/app/views/directives/_edit-command.html @@ -1,5 +1,5 @@ -

No command set.

+

No {{type || 'command'}} set.

@@ -25,15 +25,15 @@ - - Remove Argument + + Remove Item

- +
- Enter the command to run inside the container. The command is considered successful if its exit code is 0. - Drag and drop command arguments to reorder them. +
+ Enter the command to run inside the container. The command is considered successful if its exit code is 0. + Drag and drop command arguments to reorder them. +
+
+ Enter the arguments that will be appended to the container's command. Drag and drop arguments to reorder them. +
Switch to {{multiline ? 'Single-line' : 'Multiline'}} Editor | - Clear Command + Clear {{ (type || 'Command') | sentenceCase }}
diff --git a/app/views/edit/build-config.html b/app/views/edit/build-config.html index f3b49e2286..0d7d9b8495 100644 --- a/app/views/edit/build-config.html +++ b/app/views/edit/build-config.html @@ -115,7 +115,6 @@

Source Configuration

Jenkins Pipeline Configuration<
Image Configuration
- - +
Builds triggered from this Build Configuration will run one at the time, in the order they have been triggered.
Builds triggered from this Build Configuration will run all at the same time. The order in which they will finish is not guaranteed.
@@ -533,8 +529,73 @@

Run Policy

-
- {{view.advancedOptions ? 'Hide' : 'Show'}} Advanced Options +
+

Build Hooks + + + +

+ +
+ +
+ Build hooks allow you to run commands at the end of the build to verify the image. +
+
+ +
+
+

Hook Types

+ + {{$select.selected.label}} + + {{type.label}} + + +
+ +
+
+

Script

+
+
+
+ +
+

Command

+ + +
+ +
+

Arguments

+ + +
+
+
+
+ +
\n" + - "
\n" + - "{{view.advancedOptions ? 'Hide' : 'Show'}} Advanced Options\n" + + "
\n" + + "

Build Hooks\n" + + "\n" + + "Learn More \n" + + "\n" + + "

\n" + + "
\n" + + "\n" + + "
\n" + + "Build hooks allow you to run commands at the end of the build to verify the image.\n" + + "
\n" + + "
\n" + + "
\n" + + "
\n" + + "

Hook Types

\n" + + "\n" + + "{{$select.selected.label}}\n" + + "\n" + + "{{type.label}}\n" + + "\n" + + "\n" + + "
\n" + + "
\n" + + "
\n" + + "

Script

\n" + + "
\n" + + "
\n" + + "
\n" + + "
\n" + + "

Command

\n" + + "\n" + + "\n" + + "
\n" + + "
\n" + + "

Arguments

\n" + + "\n" + + "\n" + + "
\n" + + "
\n" + + "
\n" + + "
\n" + + "\n" + "
\n" + "