示例#1
0
        protected async Task CreateBuildEngineProductAsync(Product product)
        {
            var buildEngineJob = new BuildEngineJob
            {
                RequestId   = product.Id.ToString(),
                GitUrl      = product.Project.WorkflowProjectUrl,
                AppId       = product.Project.Type.Name,
                PublisherId = product.Store.Name
            };
            JobResponse jobResponse = null;

            if (SetBuildEngineEndpoint(product.Project.Organization))
            {
                jobResponse = BuildEngineApi.CreateJob(buildEngineJob);
            }
            if ((jobResponse != null) && (jobResponse.Id != 0))
            {
                product.WorkflowJobId = jobResponse.Id;
                await ProductRepository.UpdateAsync(product);

                return;
            }
            else
            {
                // TODO: Send Notification
                throw new Exception("Create job failed");
            }
        }
示例#2
0
        protected async Task CreateBuildEngineProductAsync(Product product, PerformContext context)
        {
            var buildEngineJob = new BuildEngineJob
            {
                RequestId   = product.Id.ToString(),
                GitUrl      = product.Project.WorkflowProjectUrl,
                AppId       = product.Project.Type.Name,
                PublisherId = product.Store.Name
            };
            JobResponse jobResponse = null;

            if (SetBuildEngineEndpoint(product.Project.Organization))
            {
                jobResponse = BuildEngineApi.CreateJob(buildEngineJob);
            }
            if ((jobResponse != null) && (jobResponse.Id != 0))
            {
                product.WorkflowJobId = jobResponse.Id;

                await ProductRepository.UpdateAsync(product);

                var messageParms = new Dictionary <string, object>()
                {
                    { "projectName", product.Project.Name },
                    { "productName", product.ProductDefinition.Name }
                };
                await sendNotificationService.SendNotificationToUserAsync(product.Project.Owner, "productCreatedSuccessfully", messageParms);

                return;
            }
            else
            {
                var buildEngineUrl = product.Project.Organization.BuildEngineUrl + "/job-admin";
                var messageParms   = new Dictionary <string, object>()
                {
                    { "projectName", product.Project.Name },
                    { "productName", product.ProductDefinition.Name },
                    { "buildEngineUrl", buildEngineUrl }
                };
                await SendNotificationOnFinalRetryAsync(context, product.Project.Organization, product.Project.Owner, "productCreationFailedOwner", "productCreationFailedAdmin", messageParms, buildEngineUrl);

                throw new Exception("Create job failed");
            }
        }
示例#3
0
        public void CreateTestJob()
        {
            var client = new BuildEngineApi(BaseUrl, ApiAccessKey);
            var job    = new Job
            {
                RequestId   = Guid.NewGuid().ToString(),
                GitUrl      = this.GitUrl,
                AppId       = "scriptureappbuilder",
                PublisherId = this.PublisherId
            };

            var response = client.CreateJob(job);

            Assert.NotNull(response);
            Assert.Equal(job.RequestId, response.RequestId);
            Assert.Equal(job.GitUrl, response.GitUrl);
            Assert.Equal(job.AppId, response.AppId);
            Assert.Equal(job.PublisherId, response.PublisherId);
            Assert.NotEqual(0, response.Id);
            Assert.NotEqual(DateTime.MinValue, response.Created);
            Assert.NotEqual(DateTime.MinValue, response.Updated);
        }