简体   繁体   English

带有Jenkins的ASP.NET CORE 2.2

[英]ASP.NET CORE 2.2 with Jenkins

In my .net core I have simple post action looks like: 在我的.net核心中,我有一个简单的后操作,如下所示:

    [HttpPost("create")]
    public async Task<IActionResult> CreateVm(VirtualMachine vm)
    {
        if (await _repo.VmExists(vm.Name))
            return BadRequest("VM name already exists");

        vm.Hypervisor = _context.Hypervisors.SingleOrDefault(x => x.HypervisorId == 
          vm.HypervisorId);
        vm.Project = _context.Projects.SingleOrDefault(x => x.Id == vm.ProjectId);
        vm.Management = _context.Managements.SingleOrDefault(x => x.Id == vm.ManagementId);

        try
        {
            await _context.VirtualMachines.AddAsync(vm);
            await _context.SaveChangesAsync();
        }
        catch (DbUpdateException)
        {
            return BadRequest();
        }

        return Ok();
    }

I want to implement Jenkins to this method. 我想实现詹金斯这种方法。 Logic is Jenkins will check all data and after that data will be saved to database. 逻辑是Jenkins将检查所有数据,然后将这些数据保存到数据库。 We have already Jenkins url which I tested via postman everything working fine. 我们已经有了詹金斯(Jenkins)网址,我通过邮递员对其进行了测试,一切正常。 What is the best way implement this logic? 实施此逻辑的最佳方法是什么?

Simply after the standard process build, test, deploy create additional build step to make request to that endpoint. 只需在标准流程构建之后进行测试,然后部署创建其他构建步骤,以向该端点发出请求。 If you do it before the deploy, you have to make sure you have the API and DB up which sounds more complicated. 如果在部署之前进行了此操作,则必须确保您已经安装了API和DB,这听起来更加复杂。 Hope that helps! 希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM