|
|
|
@@ -247,6 +247,29 @@ func CloudBrainStop(ctx *context.Context) { |
|
|
|
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/cloudbrain") |
|
|
|
} |
|
|
|
|
|
|
|
func CloudBrainDel(ctx *context.Context) { |
|
|
|
var jobID = ctx.Params(":jobid") |
|
|
|
task, err := models.GetCloudbrainByJobID(jobID) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("GetCloudbrainByJobID failed", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if task.Status != string(models.JobStopped) { |
|
|
|
log.Error("the job(%s) has not been stopped", task.JobName) |
|
|
|
ctx.ServerError("the job has not been stopped", errors.New("the job has not been stopped")) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
err = models.DeleteJob(task) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("UpdateJob failed", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/cloudbrain") |
|
|
|
} |
|
|
|
|
|
|
|
func downloadCode(repo *models.Repository, codePath string) error { |
|
|
|
if err := git.Clone(repo.RepoPath(), codePath, git.CloneRepoOptions{}); err != nil { |
|
|
|
log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err) |
|
|
|
|