예제 #1
0
    internal static Task <VariableGroup> AddVariableGroupAsync(this TaskAgentHttpClient client, TeamProject project, string name, IDictionary <string, VariableValue> variables, string description = null)
    {
        if (client is null)
        {
            throw new ArgumentNullException(nameof(client));
        }

        if (project is null)
        {
            throw new ArgumentNullException(nameof(project));
        }

        if (string.IsNullOrWhiteSpace(name))
        {
            throw new ArgumentException($"'{nameof(name)}' cannot be null or whitespace.", nameof(name));
        }

        if (variables is null)
        {
            throw new ArgumentNullException(nameof(variables));
        }

        if (!variables.Any())
        {
            throw new ArgumentException($"'{nameof(name)}' must contain at least one variable.", nameof(variables));
        }

        return(client.AddVariableGroupAsync(new VariableGroupParameters()
        {
            Name = name,
            Description = description,
            Type = "Vsts",
            Variables = variables,
            VariableGroupProjectReferences = new List <VariableGroupProjectReference>()
            {
                new VariableGroupProjectReference()
                {
                    Name = name,
                    Description = description,
                    ProjectReference = project.ToVariableProjectReference()
                }
            }
        }));
    }
 public async Task <VariableGroup> AddVariableGroup(VariableGroup variableGroup)
 {
     return(await _client.AddVariableGroupAsync(Credentials.PROJECT, variableGroup));
 }
        public void Add(string project, string name, VariableGroup group)
        {
            group.Name = name;

            _client.AddVariableGroupAsync(project, group).SyncResult();
        }