Commit 1959abe
Eric Bower
·
2026-08-09 11:43:44 -0400 EDT
parent fb2b232
fix: rsync dest
1 files changed,
+13,
-9
M
main.go
M
main.go
+13,
-9
| ... | ... | @@ -1743,21 +1743,22 @@ func syncJobArtifacts(cfg *Cfg, repoName, jobID string, log *slog.Logger) error | |
| 1743 | 1743 | } | |
| 1744 | 1744 | sshArgs = fmt.Sprintf("-F ~/.ssh/config -i %s%s", cfg.KeyLocation, certFile) | |
| 1745 | 1745 | } | |
| 1746 | - | // Source is jobDir (without trailing slash) so rsync creates | |
| 1747 | - | // the jobID subdirectory inside the destination folder. | |
| 1746 | + | // Source is jobDir (with trailing slash) so rsync copies | |
| 1747 | + | // the job's artifact contents directly into event.ArtifactDest. | |
| 1748 | 1748 | dest := event.ArtifactDest | |
| 1749 | 1749 | if !strings.HasSuffix(dest, "/") { | |
| 1750 | 1750 | dest += "/" | |
| 1751 | 1751 | } | |
| 1752 | + | srcDir := strings.TrimSuffix(jobDir, "/") + "/" | |
| 1752 | 1753 | var cmd *exec.Cmd | |
| 1753 | 1754 | if sshArgs != "" { | |
| 1754 | - | cmd = exec.Command("rsync", "-e", sshArgs, "-rv", jobDir, dest) | |
| 1755 | + | cmd = exec.Command("rsync", "-e", sshArgs, "-rv", srcDir, dest) | |
| 1755 | 1756 | } else { | |
| 1756 | - | cmd = exec.Command("rsync", "-rv", jobDir, dest) | |
| 1757 | + | cmd = exec.Command("rsync", "-rv", srcDir, dest) | |
| 1757 | 1758 | } | |
| 1758 | 1759 | rsyncCmd := fmt.Sprintf("rsync %s %s %s", | |
| 1759 | 1760 | strings.TrimLeft(cmd.Args[1], "-"), | |
| 1760 | - | jobDir, dest) | |
| 1761 | + | srcDir, dest) | |
| 1761 | 1762 | log.Info("rsync", "cmd", rsyncCmd) | |
| 1762 | 1763 | return runCmd(cmd, log) | |
| 1763 | 1764 | } |
| ... | ... | @@ -2227,6 +2228,10 @@ func runLocal(cfg *Cfg, dest string) error { | |
| 2227 | 2228 | _ = os.Setenv(key, val) | |
| 2228 | 2229 | } | |
| 2229 | 2230 | ||
| 2231 | + | if dest != "" { | |
| 2232 | + | eventData.ArtifactDest = strings.TrimSuffix(dest, "/") + "/" + eventData.JobID | |
| 2233 | + | } | |
| 2234 | + | ||
| 2230 | 2235 | // Auto-detect git commit SHA and branch if not explicitly provided via -e | |
| 2231 | 2236 | if eventData.Commit == "" { | |
| 2232 | 2237 | eventData.Commit = detectGitCommit(cwd) |
| ... | ... | @@ -2326,12 +2331,11 @@ func runLocal(cfg *Cfg, dest string) error { | |
| 2326 | 2331 | ||
| 2327 | 2332 | // Sync to destination if specified | |
| 2328 | 2333 | if dest != "" { | |
| 2329 | - | targetDest := strings.TrimSuffix(dest, "/") + "/" + jobID | |
| 2330 | - | fmt.Fprintf(os.Stdout, "🔄 rsyncing artifacts to %s...\n", dest) //nolint:errcheck | |
| 2331 | - | if err := syncJobArtifacts(cfg, eventData.Name, jobID, log); err != nil { | |
| 2334 | + | fmt.Fprintf(os.Stdout, "🔄 rsyncing artifacts to %s...\n", eventData.ArtifactDest) //nolint:errcheck | |
| 2335 | + | if err := syncJobArtifacts(cfg, eventData.Name, eventData.JobID, log); err != nil { | |
| 2332 | 2336 | return fmt.Errorf("sync artifacts: %w", err) | |
| 2333 | 2337 | } | |
| 2334 | - | fmt.Fprintf(os.Stdout, "✅ artifacts rsynced to %s\n", targetDest) //nolint:errcheck | |
| 2338 | + | fmt.Fprintf(os.Stdout, "✅ artifacts rsynced to %s\n", eventData.ArtifactDest) //nolint:errcheck | |
| 2335 | 2339 | } | |
| 2336 | 2340 | ||
| 2337 | 2341 | return nil |