예제 #1
0
        public async Task <Pipeline> CreateAsync(string projectName, PipelineCreateRequest pipelineCreateRequest)
        {
            var parameters = new Dictionary <string, object>();

            FluentDictionary.For(parameters)
            .Add("api-version", "6.0-preview.1");

            var response = await this.Connection.Post <Pipeline>(new Uri($"{projectName}/{EndPoint}", UriKind.Relative), pipelineCreateRequest, parameters, null)
                           .ConfigureAwait(false);

            return(response.Body);
        }
        protected override int OnExecute(CommandLineApplication app)
        {
            base.OnExecute(app);

            while (string.IsNullOrEmpty(this.Name))
            {
                this.Name = Prompt.GetString("> Pipeline Name:", null, ConsoleColor.DarkGray);
            }

            while (string.IsNullOrEmpty(this.ReposirotyId))
            {
                this.ReposirotyId = Prompt.GetString("> Repository Name or Id:", null, ConsoleColor.DarkGray);
            }

            var repository = this.DevOpsClient.Git.RepositoryGetAsync(this.ProjectName, this.ReposirotyId).GetAwaiter().GetResult();

            var configuration = new PipelineConfiguration
            {
                Path       = "azure-pipeline.yml",
                Repository = new Repository
                {
                    Id   = Guid.Parse(repository.Id),
                    Type = "azureReposGit",
                },
                Type = "yaml",
            };

            var request = new PipelineCreateRequest
            {
                Name          = this.Name,
                Configuration = configuration,
            };

            Pipeline pipeline = this.DevOpsClient.Pipeline.CreateAsync(this.ProjectName, request).GetAwaiter().GetResult();

            this.PrintOrExport(pipeline);

            return(ExitCodes.Ok);
        }