// ExecutePipelineJob executes a job of the pipeline. func (containerBuildManager *ContainerManager) ExecutePipelineJob(containerManager *docker.ContainerManager, job string) (err error) { command := containerBuildManager.buildSpec.Jobs[job] containerBuildManager.buildRegister.StartTask(job, command) log.Printf("Executing job '%s' with command: %s", job, command) err = containerManager.ExecContainer(command, containerBuildManager.buildRegister.BuildLogWriter) if err != nil { err = fmt.Errorf("Error executing job: %s. %s", job, err) } containerBuildManager.buildRegister.EndTask(job, command, err) return }
// GitProjectClone clones a GitHub project in the container. func (containerBuildManager *ContainerManager) GitProjectClone(containerManager *docker.ContainerManager, event *github.Event) error { commands := []string{ fmt.Sprintf("git clone %s .", event.CloneURL), } if event.Type == "pull" { commands = append(commands, fmt.Sprintf("git fetch origin %s:pr/merge", event.SHA)) commands = append(commands, "git checkout pr/merge") } else { commands = append(commands, fmt.Sprintf("git checkout %s", event.SHA)) } for _, command := range commands { log.Printf("Executing command: %s", command) err := containerManager.ExecContainer(command, containerBuildManager.buildRegister.BuildLogWriter) if err != nil { log.Println("Error executing command", err) return err } } return nil }