mirror of
https://github.com/theonedev/onedev.git
synced 2025-12-08 18:26:30 +00:00
Fix issue #923 - Multi level projects after import and 1dev upgrade are mingled
This commit is contained in:
parent
ac8ac2c37a
commit
5f7b656e75
2
pom.xml
2
pom.xml
@ -589,7 +589,7 @@
|
||||
</repositories>
|
||||
<properties>
|
||||
<commons.version>2.2.10</commons.version>
|
||||
<agent.version>1.4.0</agent.version>
|
||||
<agent.version>1.4.1</agent.version>
|
||||
<slf4j.version>1.7.30</slf4j.version>
|
||||
<logback.version>1.2.9</logback.version>
|
||||
<antlr.version>4.7.2</antlr.version>
|
||||
|
||||
@ -450,6 +450,7 @@ public class DefaultJobManager implements JobManager, Runnable, CodePullAuthoriz
|
||||
|
||||
private JobExecution execute(Build build) {
|
||||
Long buildId = build.getId();
|
||||
String refName = build.getRefName();
|
||||
ObjectId commitId = ObjectId.fromString(build.getCommitHash());
|
||||
Long buildNumber = build.getNumber();
|
||||
String projectPath = build.getProject().getPath();
|
||||
@ -542,8 +543,8 @@ public class DefaultJobManager implements JobManager, Runnable, CodePullAuthoriz
|
||||
JobSecretAuthorizationContext.push(build.getJobSecretAuthorizationContext());
|
||||
try {
|
||||
return new JobContext(executor, projectPath, projectId, buildNumber, projectGitDir,
|
||||
actions, job.getCpuRequirement(), job.getMemoryRequirement(), commitId,
|
||||
caches, retried.get(), services, jobLogger) {
|
||||
actions, job.getCpuRequirement(), job.getMemoryRequirement(), refName,
|
||||
commitId, caches, retried.get(), services, jobLogger) {
|
||||
|
||||
@Override
|
||||
public void notifyJobRunning(Long agentId) {
|
||||
|
||||
@ -36,6 +36,8 @@ public abstract class JobContext {
|
||||
|
||||
private final int memoryRequirement;
|
||||
|
||||
private final String refName;
|
||||
|
||||
private final ObjectId commitId;
|
||||
|
||||
private final Collection<CacheSpec> cacheSpecs;
|
||||
@ -52,8 +54,8 @@ public abstract class JobContext {
|
||||
|
||||
public JobContext(JobExecutor jobExecutor, String projectPath, Long projectId, Long buildNumber,
|
||||
File projectGitDir, List<Action> actions, int cpuRequirement, int memoryRequirement,
|
||||
ObjectId commitId, Collection<CacheSpec> caches, int retried, List<Service> services,
|
||||
TaskLogger logger) {
|
||||
String refName, ObjectId commitId, Collection<CacheSpec> caches, int retried,
|
||||
List<Service> services, TaskLogger logger) {
|
||||
this.jobExecutor = jobExecutor;
|
||||
this.projectPath = projectPath;
|
||||
this.projectId = projectId;
|
||||
@ -62,6 +64,7 @@ public abstract class JobContext {
|
||||
this.actions = actions;
|
||||
this.cpuRequirement = cpuRequirement;
|
||||
this.memoryRequirement = memoryRequirement;
|
||||
this.refName = refName;
|
||||
this.commitId = commitId;
|
||||
this.cacheSpecs = caches;
|
||||
this.retried = retried;
|
||||
@ -93,6 +96,10 @@ public abstract class JobContext {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public String getRefName() {
|
||||
return refName;
|
||||
}
|
||||
|
||||
public ObjectId getCommitId() {
|
||||
return commitId;
|
||||
}
|
||||
|
||||
@ -4373,5 +4373,5 @@ public class DataMigrator {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -68,6 +68,7 @@ public class KubernetesResource {
|
||||
context.reportJobWorkspace(jobWorkspace);
|
||||
JobData jobData = new JobData(
|
||||
context.getJobExecutor().getName(),
|
||||
context.getRefName(),
|
||||
context.getCommitId().name(),
|
||||
context.getActions());
|
||||
return SerializationUtils.serialize(jobData);
|
||||
|
||||
@ -88,9 +88,9 @@ public class RemoteDockerExecutor extends ServerDockerExecutor {
|
||||
|
||||
List<String> trustCertContent = getTrustCertContent();
|
||||
DockerJobData jobData = new DockerJobData(jobToken, getName(), jobContext.getProjectPath(),
|
||||
jobContext.getProjectId(), jobContext.getCommitId().name(), jobContext.getBuildNumber(),
|
||||
jobContext.getActions(), jobContext.getRetried(), services, registryLogins,
|
||||
mountDockerSock, trustCertContent, getRunOptions());
|
||||
jobContext.getProjectId(), jobContext.getRefName(), jobContext.getCommitId().name(),
|
||||
jobContext.getBuildNumber(), jobContext.getActions(), jobContext.getRetried(),
|
||||
services, registryLogins, mountDockerSock, trustCertContent, getRunOptions());
|
||||
|
||||
try {
|
||||
WebsocketUtils.call(agentSession, jobData, 0);
|
||||
|
||||
@ -75,8 +75,8 @@ public class RemoteShellExecutor extends ServerShellExecutor {
|
||||
|
||||
List<String> trustCertContent = getTrustCertContent();
|
||||
ShellJobData jobData = new ShellJobData(jobToken, getName(), jobContext.getProjectPath(),
|
||||
jobContext.getProjectId(), jobContext.getCommitId().name(), jobContext.getBuildNumber(),
|
||||
jobContext.getActions(), trustCertContent);
|
||||
jobContext.getProjectId(), jobContext.getRefName(), jobContext.getCommitId().name(),
|
||||
jobContext.getBuildNumber(), jobContext.getActions(), trustCertContent);
|
||||
|
||||
try {
|
||||
WebsocketUtils.call(agentSession, jobData, 0);
|
||||
|
||||
@ -375,7 +375,7 @@ public class ServerDockerExecutor extends JobExecutor implements Testable<TestDa
|
||||
int cloneDepth = checkoutFacade.getCloneDepth();
|
||||
|
||||
cloneRepository(git, jobContext.getProjectGitDir().getAbsolutePath(),
|
||||
cloneInfo.getCloneUrl(), jobContext.getCommitId().name(),
|
||||
cloneInfo.getCloneUrl(), jobContext.getRefName(), jobContext.getCommitId().name(),
|
||||
checkoutFacade.isWithLfs(), checkoutFacade.isWithSubmodules(),
|
||||
cloneDepth, ExecutorUtils.newInfoLogger(jobLogger), ExecutorUtils.newWarningLogger(jobLogger));
|
||||
} finally {
|
||||
|
||||
@ -199,7 +199,7 @@ public class ServerShellExecutor extends JobExecutor implements Testable<TestDat
|
||||
int cloneDepth = checkoutFacade.getCloneDepth();
|
||||
|
||||
cloneRepository(git, jobContext.getProjectGitDir().getAbsolutePath(),
|
||||
cloneInfo.getCloneUrl(), jobContext.getCommitId().name(),
|
||||
cloneInfo.getCloneUrl(), jobContext.getRefName(), jobContext.getCommitId().name(),
|
||||
checkoutFacade.isWithLfs(), checkoutFacade.isWithSubmodules(),
|
||||
cloneDepth, ExecutorUtils.newInfoLogger(jobLogger), ExecutorUtils.newWarningLogger(jobLogger));
|
||||
} catch (Exception e) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user