Exemplo n.º 1
0
            public SingleResponse LaunchPlan(
                string ciName, string planName, LaunchPlanRequest request)
            {
                Uri endpoint = ApiUris.GetFullUri(
                    mBaseUri, ApiEndpoints.CI.LaunchPlan,
                    ciName, planName);

                return(Internal.MakeApiRequest <LaunchPlanRequest, SingleResponse>(
                           endpoint, HttpMethod.Post, request, "launch CI plan", mApiKey));
            }
            static PlanResult Run(
                IRestApi restApi,
                string ciName,
                string planPath,
                string objectSpec,
                string comment,
                Dictionary <string, string> properties,
                int maxWaitTimeSeconds)
            {
                LaunchPlanRequest request = new LaunchPlanRequest()
                {
                    ObjectSpec = objectSpec,
                    Comment    = string.Format("MergeBot - {0}", comment),
                    Properties = properties
                };

                SingleResponse planResponse = restApi.CI.LaunchPlan(
                    ciName, planPath, request);

                GetPlanStatusResponse statusResponse =
                    Task.Run(() =>
                             WaitForFinishedPlanStatus(
                                 restApi,
                                 ciName,
                                 planResponse.Value,
                                 planPath,
                                 maxWaitTimeSeconds)
                             ).Result;

                if (statusResponse != null)
                {
                    return(new PlanResult()
                    {
                        Succeeded = statusResponse.Succeeded,
                        Explanation = statusResponse.Explanation
                    });
                }

                return(new PlanResult()
                {
                    Succeeded = false,
                    Explanation = string.Format(
                        "{0} reached the time limit to get the status " +
                        "for plan:'{1}' and executionId:'{2}'" +
                        "\nRequest details: objectSpec:'{3}' and comment:'{4}'",
                        ciName, planPath, planResponse.Value, objectSpec, comment)
                });
            }