我正在学习CI/CD.
我已经安装了来自Officicals的Gitlab和Gitlab Runner.但是,无论何时在maven-build期间运行管道,工作都会被卡住.我已经注册了跑步者并可以参加我的项目,但是工作陷入困境
.gitlab-ci.yml
image: docker:latest
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay
SPRING_PROFILES_ACTIVE: gitlab-ci
stages:
- build
- package
- deploy
maven-build:
image: maven:3-jdk-8
stage: build
script: "mvn package -B"
artifacts:
paths:
- target/*.jar
docker-build:
stage: package
script:
- docker build -t registry.com/ci-cd-demo .
- docker push registry.com/ci-cd-demo
k8s-deploy:
image: google/cloud-sdk
stage: deploy
script:
- echo "$GOOGLE_KEY" > key.json
- gcloud container clusters get-credentials standard-cluster-demo --
zone us-east1-c --project ascendant-study-222206
- kubectl apply -f deployment.yml
Run Code Online (Sandbox Code Playgroud)
我的跑步者设置
跑步者已与项目关联时出现错误消息
请帮忙?
我正在使用 EF Core 2.0 和 Postgres 9.6。每当我插入数据时,我都会收到错误
PostgresException:23505:重复的键值违反唯一约束“PK_country”
通过跟踪它看起来像 EF 不生成 AutoIncrement 列
我的模特
public partial class Country
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int CountryId { get; set; }
[Display(Name="Country Name")]
public string CountryName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的控制器
if (ModelState.IsValid)
{
_context.Add(country);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
Run Code Online (Sandbox Code Playgroud)
例外
Run Code Online (Sandbox Code Playgroud)> PostgresException: 23505: duplicate key value violates unique > constraint "PK_country" > > Npgsql.NpgsqlConnector+<DoReadMessage>d__148.MoveNext() > System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() > System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task > task) > System.Runtime.CompilerServices.TaskAwaiter.GetResult() > System.Runtime.CompilerServices.ValueTaskAwaiter.GetResult() > Npgsql.NpgsqlConnector+<ReadMessage>d__147.MoveNext() > System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() > Npgsql.NpgsqlConnector+<ReadMessage>d__147.MoveNext() > …
c# entity-framework npgsql entity-framework-core asp.net-core-2.0
我想尝试像这样的会议
@HttpContext.Session.GetString("some");
Run Code Online (Sandbox Code Playgroud)
但我得到了
*
非静态字段需要对象引用......
*
有想法的人吗?
在我的控制器中,我有这个
private readonly DbContext _context;
public CountryController(DbContext context)
{
_context = context;
}
Run Code Online (Sandbox Code Playgroud)
如何在其他类(如静态类)中检索 DbContext 而不将其作为参数传递给方法调用
我有一个创建模型属性并传递给视图“partial.html”以生成输出的控制器
部分.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Home page</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<p>
<span th:text="'Today is: ' + ${message}"></span>
</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
并在控制器方法中
model.addAttribute("message", search);
Run Code Online (Sandbox Code Playgroud)
如何将 Htlm 输出到控制器方法中的字符串?像这样
String htmlOutput="from partial.html";
Run Code Online (Sandbox Code Playgroud) android ×1
asp.net-mvc ×1
c# ×1
dbcontext ×1
gitlab ×1
npgsql ×1
spring ×1
spring-boot ×1
thymeleaf ×1