コード例 #1
0
        public async Task CreatePullRequestAsync(IPullRequestInfo pullRequestInfo)
        {
            try
            {
                var creds = new VssBasicCredential(string.Empty, _config.Token);

                using (var connection = new VssConnection(new Uri(_config.BaseUrl), creds))
                {
                    var gitClient = connection.GetClient <GitHttpClient>();

                    var result = await gitClient.CreatePullRequestAsync(new GitPullRequest
                    {
                        SourceRefName = $"refs/heads/{pullRequestInfo.SourceBranch}",
                        TargetRefName = "refs/heads/master",
                        Title         = pullRequestInfo.Title,
                        Description   = pullRequestInfo.Description,
                    },
                                                                        project : _config.Project,
                                                                        repositoryId : _config.Repository
                                                                        );
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #2
0
        public async Task DeploymentNotification(DeploymentNotificationInputs inputs)
        {
            string     repositoryUrl = HttpUtility.UrlDecode(inputs.deployInputs.repoUrl);
            string     token         = GetTokenFromHeader();
            Repository repo          = Repository.CreateRepositoryObj(repositoryUrl, Request.RequestUri.Host, token);

            Uri repoUri      = new Uri(repositoryUrl);
            var queryStrings = HttpUtility.ParseQueryString(repoUri.Query);

            if (queryStrings["pr"] != null)
            {
                // if deployment is come from a pull request, post a comment back to the pull request.
                string        siteUrl = inputs.siteUrl;
                StringBuilder prMsg   = new StringBuilder();
                prMsg.Append("***\n[![Azure App Service](http://deployredirector.azurewebsites.net/AzureLogo.png)](https://azure.microsoft.com/en-us/services/app-service) A web app has been deployed to Azure App Service from this pull request");

                bool isManualIntegration = true;
                if (inputs.deployInputs.parameters["isManualIntegration"] != null &&
                    inputs.deployInputs.parameters["isManualIntegration"]["value"] != null &&
                    bool.TryParse(inputs.deployInputs.parameters["isManualIntegration"]["value"].ToString(), out isManualIntegration) &&
                    !isManualIntegration)
                {
                    prMsg.Append(" with continuous deployment enabled");
                }

                prMsg.AppendFormat(": {0}.", siteUrl);

                string           prId   = queryStrings["pr"];
                IPullRequestInfo prInfo = await repo.GetPullRequest(prId);

                prInfo.AppendNewLineToDescription(prMsg.ToString());
                await repo.UpdatePullRequest(prId, prInfo);
            }
        }
コード例 #3
0
 public override async Task UpdatePullRequest(string prId, IPullRequestInfo prInfo)
 {
     try
     {
         using (HttpClient client = await CreateHttpClient())
         {
             var requestUrl = string.Format(CultureInfo.InvariantCulture, Constants.Repository.BitbucketApiPullRequestInfoFormat, UserName, RepositoryName, prId);
             await client.PutAsJsonAsync <object>(requestUrl, ((BitBucketPullRequest)prInfo).RawContent);
         }
     }
     catch (Exception ex)
     {
         throw new InvalidOperationException(string.Format("Failed to update Pull Request: {0}. {1}", prId, ex.Message));
     }
 }
コード例 #4
0
ファイル: BitbucketRepository.cs プロジェクト: 40a/slingshot
 public override async Task UpdatePullRequest(string prId, IPullRequestInfo prInfo)
 {
     try
     {
         using (HttpClient client = await CreateHttpClient())
         {
             var requestUrl = string.Format(CultureInfo.InvariantCulture, Constants.Repository.BitbucketApiPullRequestInfoFormat, UserName, RepositoryName, prId);
             await client.PutAsJsonAsync<object>(requestUrl, ((BitBucketPullRequest)prInfo).RawContent);
         }
     }
     catch (Exception ex)
     {
         throw new InvalidOperationException(string.Format("Failed to update Pull Request: {0}. {1}", prId, ex.Message));
     }
 }
コード例 #5
0
ファイル: Repository.cs プロジェクト: sjkp/policydemo2
 public virtual Task UpdatePullRequest(string prId, IPullRequestInfo prInfo)
 {
     return(Task.FromResult(new object()));
 }
コード例 #6
0
ファイル: Repository.cs プロジェクト: 40a/slingshot
 public virtual Task UpdatePullRequest(string prId, IPullRequestInfo prInfo)
 {
     return Task.FromResult(new object());
 }