public IList <ManualIntervention> GetManualInterventions()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;

            // Get a release client instance
            VssConnection     connection    = Context.Connection;
            ReleaseHttpClient releaseClient = connection.GetClient <ReleaseHttpClient>();

            IList <ManualIntervention> manualInterventions = null;

            // Get all manual interventions
            ClientSampleHelpers.Retry(
                TimeSpan.FromMinutes(2),
                TimeSpan.FromSeconds(5),
                () =>
            {
                manualInterventions = releaseClient.GetManualInterventionsAsync(project: projectName, releaseId: this._newlyCreatedRelease1.Id).Result;
                return(manualInterventions.Count > 0);
            });

            foreach (ManualIntervention manualIntervention in manualInterventions)
            {
                Context.Log("{0} {1}", manualIntervention.Id.ToString().PadLeft(6), manualIntervention.Name);
            }

            this._manualInterventions = manualInterventions;

            return(manualInterventions);
        }
Example #2
0
        public IEnumerable <Release> GetReleases(
            int definitionId,
            string accessToken,
            int?artifactVersionId = null,
            int?prereqEnvId       = null)
        {
            if (definitionId < 0)
            {
                throw new ArgumentException("id cannot be less than 0", nameof(definitionId));
            }
            if (string.IsNullOrWhiteSpace(accessToken))
            {
                throw new ArgumentException("parameter cannot be null or whitespace", nameof(accessToken));
            }

            this.logger.LogDebug($"getting releases. definitionId:[{definitionId}], artifaction version id:[{artifactVersionId}], prereq environment id:[{prereqEnvId}]");

            ReleaseHttpClient client = this.GetClient <ReleaseHttpClient>(accessToken);

            bool hasArtifactVersionId    = artifactVersionId.HasValue && artifactVersionId > 0;
            bool hasPrereqEnvId          = prereqEnvId.HasValue && prereqEnvId > 0;
            int? environmentStatusFilter = this.GetEnvironmentStatusFilter();

            return(client.GetReleasesAsync(
                       this.vstsConfig.ProjectName,
                       definitionId,
                       statusFilter: ReleaseStatus.Active,
                       artifactVersionId: hasArtifactVersionId ? artifactVersionId.ToString() : null,
                       definitionEnvironmentId: prereqEnvId,
                       environmentStatusFilter: hasArtifactVersionId ? environmentStatusFilter : (int?)null,
                       expand: ReleaseExpands.Artifacts).Result);
        }
        public System.IO.Stream GetReleaseTaskAttachmentContent()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;

            // Get a release client instance
            VssConnection     connection    = Context.Connection;
            ReleaseHttpClient releaseClient = connection.GetClient <ReleaseHttpClient>();

            WebApiRelease release = releaseClient.GetReleaseAsync(project: projectName, releaseId: this._newlyCreatedRelease).Result;

            // Get release task attachments
            ReleaseEnvironment environment = release.Environments.FirstOrDefault();
            DeploymentAttempt  deployStep  = environment.DeploySteps.First();
            Guid planId = deployStep.ReleaseDeployPhases.First().RunPlanId.Value;

            List <ReleaseTaskAttachment> releaseTaskAttachment = releaseClient.GetReleaseTaskAttachmentsAsync(project: projectName, releaseId: release.Id, environmentId: environment.Id, attemptId: deployStep.Attempt, planId: planId, type: "myattachmenttype").Result;

            ReleaseTaskAttachment firstReleaseTaskAttachment = releaseTaskAttachment.First();
            Guid   timelineId     = firstReleaseTaskAttachment.TimelineId;
            Guid   recordId       = firstReleaseTaskAttachment.RecordId;
            string attachmentType = firstReleaseTaskAttachment.Type;
            string attachmentName = firstReleaseTaskAttachment.Name;

            System.IO.Stream attachmentData = releaseClient.GetReleaseTaskAttachmentContentAsync(project: projectName, releaseId: release.Id, environmentId: environment.Id, attemptId: deployStep.Attempt, planId: planId, timelineId: timelineId, recordId: recordId, type: attachmentType, name: attachmentName).Result;

            Context.Log("{0} {1}", attachmentName.PadLeft(6), attachmentType);

            return(attachmentData);
        }
Example #4
0
 protected ReleaseRestAPIProvider(string alias, string token, string organizationName,
                                  string projectName, ReleaseHttpClient releaseHttpClient) : base(GetClientUsingBasicAuth(alias, token))
 {
     this.releaseHttpClient = releaseHttpClient;
     this.projectName       = projectName;
     this.organizationName  = organizationName;
 }
        public async Task <VstsRelease> CreateRelease(ReleaseHttpClient releaseClient, int releaseDefinitionId, string projectName, Dictionary <string, ConfigurationVariableValue> overrideVaraibles = null)
        {
            ReleaseStartMetadata releaseStartMetaData = new ReleaseStartMetadata();

            releaseStartMetaData.DefinitionId = releaseDefinitionId;
            releaseStartMetaData.Description  = "Release created by das-self-service";

            if (overrideVaraibles != null)
            {
                // If you want to override varaibles at release create time, 'AllowOverride' on variable should be set while creating RD.
                // You can override environment level variables using releaseStartMetaData.EnvironmentsMetadata.Variables.
                releaseStartMetaData.Variables = overrideVaraibles;
            }

            // Create  a release
            var release = await
                          releaseClient.CreateReleaseAsync(project : projectName, releaseStartMetadata : releaseStartMetaData);

            return(new VstsRelease
            {
                Id = release.Id,
                ReleaseName = release.Name,
                ReleaseDefininitionId = release.ReleaseDefinitionReference.Id,
                ReleaseEnvironments = release.Environments.Select(x => new VstsEnvironment {
                    DefinitionId = x.DefinitionEnvironmentId, EnvironmentReleaseId = x.Id, Name = x.Name
                }).ToList()
            });
        }
        public async Task ConnectAsync(VssConnection jobConnection)
        {
            ArgUtil.NotNull(jobConnection, nameof(jobConnection));

            _connection = jobConnection;
            int attemptCount = 5;

            while (!_connection.HasAuthenticated && attemptCount-- > 0)
            {
                try
                {
                    await _connection.ConnectAsync();

                    break;
                }
                catch (SocketException ex)
                {
                    ExceptionsUtil.HandleSocketException(ex, _connection.Uri.ToString(), Trace.Error);
                }
                catch (Exception ex) when(attemptCount > 0)
                {
                    Trace.Info($"Catch exception during connect. {attemptCount} attemp left.");
                    Trace.Error(ex);
                }

                await Task.Delay(100);
            }

            _releaseHttpClient = _connection.GetClient <ReleaseHttpClient>();
        }
        public ManualIntervention RejectManualIntervention()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;

            // Get a release client instance
            VssConnection     connection    = Context.Connection;
            ReleaseHttpClient releaseClient = connection.GetClient <ReleaseHttpClient>();

            ManualInterventionUpdateMetadata manualInterventionUpdateMetadata = new ManualInterventionUpdateMetadata()
            {
                Status  = ManualInterventionStatus.Rejected,
                Comment = "Reject MI"
            };

            IList <ManualIntervention> manualInterventions = null;

            // Get all manual interventions
            ClientSampleHelpers.Retry(
                TimeSpan.FromMinutes(2),
                TimeSpan.FromSeconds(5),
                () =>
            {
                manualInterventions = releaseClient.GetManualInterventionsAsync(project: projectName, releaseId: this._newlyCreatedRelease2.Id).Result;
                return(manualInterventions.Count > 0);
            });

            // Update a manual intervention
            ManualIntervention manualIntervention = releaseClient.UpdateManualInterventionAsync(manualInterventionUpdateMetadata: manualInterventionUpdateMetadata, project: projectName, releaseId: this._newlyCreatedRelease2.Id, manualInterventionId: manualInterventions.FirstOrDefault().Id).Result;

            Context.Log("{0} {1}", manualIntervention.Id.ToString().PadLeft(6), manualIntervention.Name);

            return(manualIntervention);
        }
        public WebApiRelease UpdateRelease()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;

            // Get a release client instance
            VssConnection     connection    = Context.Connection;
            ReleaseHttpClient releaseClient = connection.GetClient <ReleaseHttpClient>();

            List <WebApiRelease> releases = releaseClient.GetReleasesAsync(project: projectName).Result;
            int releaseId = releases.FirstOrDefault().Id;

            WebApiRelease release = releaseClient.GetReleaseAsync(project: projectName, releaseId: releaseId).Result;

            IDictionary <string, ConfigurationVariableValue> varaibles = release.Variables;

            varaibles.Add(
                new KeyValuePair <string, ConfigurationVariableValue>("System.Debug", new ConfigurationVariableValue
            {
                AllowOverride = true, IsSecret = false, Value = "false"
            }
                                                                      )
                );

            // Update the release
            WebApiRelease updatedRelease = releaseClient.UpdateReleaseAsync(release: release, project: projectName, releaseId: releaseId).Result;

            Context.Log("{0} {1}", release.Id.ToString().PadLeft(6), updatedRelease.Name);

            return(release);
        }
Example #9
0
        public ReleaseEnvironment UpdateReleaseEnvironment(int releaseId, int targetEnvId, string accessToken)
        {
            if (releaseId < 0)
            {
                throw new ArgumentException("id cannot be less than 0", nameof(releaseId));
            }
            if (targetEnvId < 0)
            {
                throw new ArgumentException("id cannot be less than 0", nameof(targetEnvId));
            }
            if (string.IsNullOrWhiteSpace(accessToken))
            {
                throw new ArgumentException("parameter cannot be null or whitespace", nameof(accessToken));
            }

            this.logger.LogDebug($"updating release environment. release id:[{releaseId}], target environment id:[{targetEnvId}]");

            ReleaseHttpClient client = this.GetClient <ReleaseHttpClient>(accessToken);

            ReleaseEnvironmentUpdateMetadata environmentMetadata = new ReleaseEnvironmentUpdateMetadata()
            {
                Status  = EnvironmentStatus.InProgress,
                Comment = DeployMessage
            };

            return(client.UpdateReleaseEnvironmentAsync(
                       environmentMetadata,
                       this.vstsConfig.ProjectName,
                       releaseId,
                       targetEnvId).Result);
        }
        public static WebApiRelease CreateRelease(ReleaseHttpClient releaseClient, int releaseDefinitionId, string projectName, Dictionary <string, ConfigurationVariableValue> overrideVaraibles = null)
        {
            BuildVersion instanceReference = new BuildVersion {
                Id = "2"
            };
            ArtifactMetadata artifact = new ArtifactMetadata {
                Alias = "Fabrikam.CI", InstanceReference = instanceReference
            };
            ReleaseStartMetadata releaseStartMetaData = new ReleaseStartMetadata();

            releaseStartMetaData.DefinitionId = releaseDefinitionId;
            releaseStartMetaData.Description  = "Creating Sample release";

            if (overrideVaraibles != null)
            {
                // If you want to override varaibles at release create time, 'AllowOverride' on variable should be set while creating RD.
                // You can override environment level variables using releaseStartMetaData.EnvironmentsMetadata.Variables.
                releaseStartMetaData.Variables = overrideVaraibles;
            }

            releaseStartMetaData.Artifacts = new[] { artifact };
            // Create  a release
            WebApiRelease release =
                releaseClient.CreateReleaseAsync(project: projectName, releaseStartMetadata: releaseStartMetaData).Result;

            return(release);
        }
Example #11
0
        static void RunOptions(Options opts)
        {
            VssCredentials creds = new VssBasicCredential(string.Empty, personalAccessToken);

            // Connect to Azure DevOps Services
            VssConnection connection = new VssConnection(new Uri(collectionUri), creds);

            // Get a Release EndPoint
            ReleaseHttpClient releaseHttpClient = connection.GetClient <ReleaseHttpClient>();

            // Get data about a specific repository
            ReleaseDefinition definition = releaseHttpClient.GetReleaseDefinitionAsync(opts.ProjectName, opts.ReleaseId).Result;

            List <ReleaseDefinitionEnvironment> environments = definition.Environments as List <ReleaseDefinitionEnvironment>;

            environments.Sort();


            foreach (var env in environments)
            {
                Console.WriteLine();
                Console.WriteLine($"## {env.Name}");
                Console.WriteLine();

                foreach (var variable in env.Variables)
                {
                    Console.WriteLine($"{variable.Key}#{variable.Value.Value}");
                }
            }
        }
Example #12
0
        protected bool Connect(string PAT, string organisation)
        {
            var uriString = $"https://dev.azure.com/{organisation}";

            Console.Write($"Connecting to Azure DevOps REST API, {uriString} ...");
            try
            {
                _credentials     = new VssBasicCredential(string.Empty, PAT);
                _connection      = new VssConnection(new Uri(uriString), _credentials);
                _projectClient   = _connection.GetClient <ProjectHttpClient>();
                _buildClient     = _connection.GetClient <BuildHttpClient>();
                _releaseClient   = _connection.GetClient <ReleaseHttpClient>();
                _taskAgentClient = _connection.GetClient <TaskAgentHttpClient>();
                _extensionClient = _connection.GetClient <ExtensionManagementHttpClient>();
                _endpointClient  = _connection.GetClient <ServiceEndpointHttpClient>();
                _apiService      = new ApiService(PAT);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                Console.WriteLine($"Unable to authenticate with Azure DevOps REST API :(");
                return(false);
            }
            Console.WriteLine($" connected :)");
            return(true);
        }
Example #13
0
        public ReleaseApproval UpdateApproval(int approvalId, string accessToken)
        {
            if (approvalId < 0)
            {
                throw new ArgumentException("id cannot be less than 0", nameof(approvalId));
            }
            if (string.IsNullOrWhiteSpace(accessToken))
            {
                throw new ArgumentException("parameter cannot be null or whitespace", nameof(accessToken));
            }

            this.logger.LogDebug($"updating approval. approval id:[{approvalId}]");

            ReleaseApproval approval = new ReleaseApproval
            {
                Status   = ApprovalStatus.Approved,
                Comments = ApproveMessage
            };

            ReleaseHttpClient client = this.GetClient <ReleaseHttpClient>(accessToken);

            return(client.UpdateReleaseApprovalAsync(
                       approval,
                       this.vstsConfig.ProjectName,
                       approvalId).Result);
        }
        public ReleaseRequester()
        {
            VssCredentials creds = new VssBasicCredential(string.Empty, Credentials.TOKEN);

            VssConnection connection = new VssConnection(new Uri($"{Url}/{Credentials.ORGANIZATION}"), creds);

            _client = connection.GetClient <ReleaseHttpClient>();
        }
Example #15
0
        static Release CreateRelease(ReleaseHttpClient rmClient, ReleaseDefinition releaseDefinition)
        {
            ReleaseStartMetadata rmMetaData = new ReleaseStartMetadata();

            rmMetaData.DefinitionId = releaseDefinition.Id;

            return(rmClient.CreateReleaseAsync(rmMetaData, project: projectName).Result);
        }
Example #16
0
        static ReleaseEnvironment DeployAnEnvironment(ReleaseHttpClient rmClient, int releaseId, int environmentIdToDeploy)
        {
            ReleaseEnvironmentUpdateMetadata envMetaData = new ReleaseEnvironmentUpdateMetadata();

            envMetaData.Status  = EnvironmentStatus.InProgress;
            envMetaData.Comment = "Good to go";
            return(rmClient.UpdateReleaseEnvironmentAsync(envMetaData, projectName, releaseId, environmentIdToDeploy).Result);
        }
Example #17
0
        public ReleaseServer(VssConnection connection, Guid projectId)
        {
            ArgUtil.NotNull(connection, nameof(connection));

            _connection = connection;
            _projectId  = projectId;

            _releaseHttpClient = _connection.GetClient <ReleaseHttpClient>();
        }
Example #18
0
        public VstsClient(Config config)
        {
            _config      = config;
            _projectName = config.ProjectName;
            var baseUrl    = $"https://{config.AccountName}.visualstudio.com";
            var connection = new VssConnection(new Uri(baseUrl), new VssBasicCredential("username", config.AccessToken));

            _client = connection.GetClient <ReleaseHttpClient>();
        }
Example #19
0
        static void GetReleaseTasks(ReleaseHttpClient rmClient)
        {
            int releaseId            = 132;
            int releaseEnvironmentId = 168;
            int releaseDeployPhaseId = 129;

            var releaseTaskAcrossAllPhase = rmClient.GetTasksAsync(projectName, releaseId, releaseEnvironmentId).Result;
            var releaseTaskForAPhaseId    = rmClient.GetTasksForTaskGroupAsync(projectName, releaseId, releaseEnvironmentId, releaseDeployPhaseId).Result;
        }
Example #20
0
        public TfsRelease(TfsInfo TfsEnvInfo, string pat)
        {
            this.TfsEnvInfo = TfsEnvInfo;

            // Use PAT in order to perform rest calls
            VssConnection connection = new VssConnection(new Uri(this.TfsEnvInfo.ProjectCollectionUrl), new VssBasicCredential(string.Empty, pat));

            relclient  = connection.GetClient <ReleaseHttpClient>();
            projclient = connection.GetClient <ProjectHttpClient>();
        }
Example #21
0
        public VstsClient(Config config)
        {
            _config        = config;
            _projectName   = config.ProjectName;
            _baseUrl       = $"https://{config.AccountName}.visualstudio.com";
            _releaseClient = new VssConnection(new Uri(_baseUrl), new VssBasicCredential("username", config.AccessToken)).GetClient <ReleaseHttpClient>();
            _buildClient   = new VssConnection(new Uri(_baseUrl), new VssBasicCredential("username", config.AccessToken)).GetClient <BuildHttpClient>();

            _prClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.UTF8.GetBytes(config.AccessToken)));
        }
Example #22
0
 static void InitClients(VssConnection Connection)
 {
     WitClient            = Connection.GetClient <WorkItemTrackingHttpClient>();
     BuildClient          = Connection.GetClient <BuildHttpClient>();
     ProjectClient        = Connection.GetClient <ProjectHttpClient>();
     TeamClient           = Connection.GetClient <TeamHttpClient>();
     GitClient            = Connection.GetClient <GitHttpClient>();
     TfvsClient           = Connection.GetClient <TfvcHttpClient>();
     TestManagementClient = Connection.GetClient <TestManagementHttpClient>();
     ReleaseClient        = Connection.GetClient <ReleaseHttpClient>();
 }
Example #23
0
        public ReleaseServer(Uri projectCollection, VssCredentials credentials, Guid projectId)
        {
            ArgUtil.NotNull(projectCollection, nameof(projectCollection));
            ArgUtil.NotNull(credentials, nameof(credentials));

            _projectCollectionUrl = projectCollection;
            _credential           = credentials;
            _projectId            = projectId;

            _releaseHttpClient = new ReleaseHttpClient(projectCollection, credentials, new VssHttpRetryMessageHandler(3));
        }
Example #24
0
        public ReleaseServer(Uri projectCollection, VssCredentials credentials, Guid projectId)
        {
            ArgUtil.NotNull(projectCollection, nameof(projectCollection));
            ArgUtil.NotNull(credentials, nameof(credentials));

            _projectCollectionUrl = projectCollection;
            _credential = credentials;
            _projectId = projectId;

            _releaseHttpClient = new ReleaseHttpClient(projectCollection, credentials, new VssHttpRetryMessageHandler(3));
        }
Example #25
0
        public void DeleteReleaseDefinition()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;

            // Get a release client instance
            VssConnection     connection    = Context.Connection;
            ReleaseHttpClient releaseClient = connection.GetClient <ReleaseHttpClient>();

            // delete release definition
            releaseClient.DeleteReleaseDefinitionAsync(project: projectName, definitionId: newlyCreatedReleaseDefinitionId).SyncResult();
        }
        public async Task StartEnvironmentDeployment(VstsRelease vstsRelease, int releaseEnvironmentId)
        {
            ReleaseHttpClient releaseClient = _vssConnection.GetClient <ReleaseHttpClient>();

            ReleaseEnvironmentUpdateMetadata releaseEnvironmentUpdateMetadata = new ReleaseEnvironmentUpdateMetadata()
            {
                Status = EnvironmentStatus.InProgress
            };

            await releaseClient.UpdateReleaseEnvironmentAsync(releaseEnvironmentUpdateMetadata, _configuration.Value.ProjectName, vstsRelease.Id, releaseEnvironmentId);
        }
Example #27
0
        static ReleaseDefinition CreateReleaseDefinition(ReleaseHttpClient rmClient, string rdJson)
        {
            var definition = JsonConvert.DeserializeObject <ReleaseDefinition>(rdJson);

            definition.CreatedBy  = null;
            definition.ModifiedBy = null;
            definition.Name       = string.Format("{0} - Copy ", definition.Name);

            var newDefinition = rmClient.CreateReleaseDefinitionAsync(definition, projectName).Result;

            return(newDefinition);
        }
Example #28
0
        public RestHelper(string url, string pat, TfsInfo tfsinfo)
        {
            TfsEnvInfo = tfsinfo;

            // Initialize connection to azure devops
            personalaccesstoken = pat;
            var           networkCredential = new VssBasicCredential(string.Empty, pat);
            VssConnection connection        = new VssConnection(new Uri(url), networkCredential);

            relclient   = connection.GetClient <ReleaseHttpClient>();
            buildclient = connection.GetClient <BuildHttpClient>();
            projclient  = connection.GetClient <ProjectHttpClient>();

            // Initialize latest return entities
            Build   latestBuild   = new Build();
            Release latestRelease = new Release();
            Build   latestBuildForSpecifiedDefinition   = new Build();
            Release latestReleaseForSpecifiedDefinition = new Release();

            // Get latest successful build and release for a project
            latestBuild   = GetLatestSuccessfulBuild();
            latestRelease = GetLatestSuccessfulRelease();

            Console.WriteLine("latest Successful Build:");
            Console.WriteLine("--------------------------");
            Console.WriteLine("id=" + latestBuild.Id);
            Console.WriteLine("starttime=" + latestBuild.StartTime);
            Console.WriteLine("finishtime=" + latestBuild.FinishTime);
            Console.WriteLine();
            Console.WriteLine("latest Successful Release:");
            Console.WriteLine("--------------------------");
            Console.WriteLine("id=" + latestRelease.Id);
            Console.WriteLine("modifiedon=" + latestRelease.ModifiedOn);
            Console.WriteLine();
            Console.WriteLine();

            // Get latest successful build and release for a project/specified build/release definition id
            latestBuildForSpecifiedDefinition   = GetLatestSuccessfulBuild(TfsEnvInfo.BuildDefinitionId);
            latestReleaseForSpecifiedDefinition = GetLatestSuccessfulRelease(true);

            Console.WriteLine("latest Successful Build For Specified Definition:");
            Console.WriteLine("-------------------------------------------------");
            Console.WriteLine("id=" + latestBuildForSpecifiedDefinition.Id);
            Console.WriteLine("starttime=" + latestBuildForSpecifiedDefinition.StartTime);
            Console.WriteLine("finishtime=" + latestBuildForSpecifiedDefinition.FinishTime);
            Console.WriteLine();
            Console.WriteLine("latest Successful Release For Specified Definition:");
            Console.WriteLine("---------------------------------------------------");
            Console.WriteLine("id=" + latestReleaseForSpecifiedDefinition.Id);
            Console.WriteLine("modifiedon=" + latestReleaseForSpecifiedDefinition.ModifiedOn);
            Console.WriteLine();
            Console.WriteLine();
        }
        public System.IO.Stream GetLogsOfRelease()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;

            // Get a release client instance
            VssConnection     connection    = Context.Connection;
            ReleaseHttpClient releaseClient = connection.GetClient <ReleaseHttpClient>();

            System.IO.Stream taskLogs = releaseClient.GetLogsAsync(project: projectName, releaseId: completedReleaseId).Result;
            Context.Log("{0} {1}", completedReleaseId.ToString().PadLeft(6), completedReleaseId);

            return(taskLogs);
        }
Example #30
0
        public WebApiRelease CreateRelease()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;

            // Get a release client instance
            VssConnection     connection    = Context.Connection;
            ReleaseHttpClient releaseClient = connection.GetClient <ReleaseHttpClient>();

            WebApiRelease release = CreateRelease(releaseClient, newlyCreatedReleaseDefinitionId, projectName);

            Console.WriteLine("{0} {1}", release.Id.ToString().PadLeft(6), release.Name);

            return(release);
        }
        public async Task <IList <VstsReleaseStatus> > CheckReleaseStatus(int releaseDefinitionId, int releaseId)
        {
            ReleaseHttpClient releaseClient = _vssConnection.GetClient <ReleaseHttpClient>();

            List <Deployment> deployments = await releaseClient.GetDeploymentsAsync(project : _configuration.Value.ProjectName, definitionId : releaseDefinitionId, top : 25);

            var deployment = deployments.Where(r => r.Release.Id == releaseId).OrderBy(x => x.ReleaseEnvironmentReference.Id).ToList();

            List <VstsReleaseStatus> vstsReleaseStatus = deployment.Select(x => new VstsReleaseStatus {
                Name = x.ReleaseEnvironmentReference.Name, ReleaseStatus = (VstsReleaseStatus.Status)x.DeploymentStatus
            }).ToList();

            return(vstsReleaseStatus);
        }