Exemplo n.º 1
0
        public static void SetOutputVariable(this IVariables variables, string name, string?value)
        {
            variables.Set(name, value);

            // And set the output-variables.
            // Assuming we are running in a step named 'DeployWeb' and are setting a variable named 'Foo'
            // then we will set Octopus.Action[DeployWeb].Output.Foo
            var actionName = variables.Get(ActionVariables.Name);

            if (string.IsNullOrWhiteSpace(actionName))
            {
                return;
            }

            var actionScopedVariable = ActionVariables.GetOutputVariableName(actionName, name);

            variables.Set(actionScopedVariable, value);

            // And if we are on a machine named 'Web01'
            // Then we will set Octopus.Action[DeployWeb].Output[Web01].Foo
            var machineName = variables.Get(MachineVariables.Name);

            if (string.IsNullOrWhiteSpace(machineName))
            {
                return;
            }

            var machineIndexedVariableName = ActionVariables.GetMachineIndexedOutputVariableName(actionName, machineName, name);

            variables.Set(machineIndexedVariableName, value);
        }
Exemplo n.º 2
0
            /// <summary>
            /// This method returns the list of variables in the log file from the log descriptor
            /// in the same order as they are defined in the descriptor
            /// </summary>
            /// <returns>The list of variables read from the log descriptor</returns>
            public Descriptor(string logDescriptorFileName)
            {
                List <string> variableList  = new List <string>();
                XmlDocument   logDescriptor = new XmlDocument();

                if (File.Exists(logDescriptorFileName))
                {
                    try
                    {
                        logDescriptor.Load(logDescriptorFileName);
                        XmlNode node = logDescriptor.FirstChild;
                        if (node.Name == XMLTags.descriptorRootNodeName)
                        {
                            if (node.Attributes.GetNamedItem(XMLTags.descriptorBinaryDataFile) != null)
                            {
                                BinaryLogFile = node.Attributes[XMLTags.descriptorBinaryDataFile].Value;
                            }
                            if (node.Attributes.GetNamedItem(XMLTags.descriptorSceneFile) != null)
                            {
                                SceneFile = node.Attributes[XMLTags.descriptorSceneFile].Value;
                            }

                            foreach (XmlNode child in node.ChildNodes)
                            {
                                string variableName = child.InnerText;
                                switch (child.Name)
                                {
                                case XMLTags.descriptorStateVarNodeName: StateVariables.Add(variableName); break;

                                case XMLTags.descriptorActionVarNodeName: ActionVariables.Add(variableName); break;

                                case XMLTags.descriptorRewardVarNodeName: RewardVariables.Add(variableName); break;

                                case XMLTags.descriptorStatVarNodeName: StatVariables.Add(variableName); break;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Error loading log descriptor: " + logDescriptorFileName + ex.Message);
                    }
                }
            }