Skip to content

Commit

Permalink
Merge pull request #278 from jenkins-x-plugins/orderlogs
Browse files Browse the repository at this point in the history
feat: show logs in creation time order
  • Loading branch information
jenkins-x-bot authored Sep 4, 2023
2 parents ae30c57 + f8d774f commit f72f951
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 45 deletions.
42 changes: 0 additions & 42 deletions .github/workflows/jenkins-x-pr.yaml

This file was deleted.

11 changes: 8 additions & 3 deletions pkg/cmd/joblog/joblog.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,13 @@ func (o *Options) viewJobLog(client kubernetes.Interface, ns string, selector st
}

var answer error
for i := range podList.Items {
pod := &podList.Items[i]
pos := podList.Items
// Sort pods in creation time order
sort.Slice(pos, func(i, j int) bool {
return pos[i].CreationTimestamp.Before(&pos[j].CreationTimestamp)
})
for i := range pos {
pod := &pos[i]

// lets verify the container name
err = verifyContainerName(pod, containerName)
Expand All @@ -264,7 +269,7 @@ func (o *Options) viewJobLog(client kubernetes.Interface, ns string, selector st
return errors.Wrapf(err, "failed to wait for pod %s to be running", pod.Name)
}
podName := pod.Name
logger.Logger().Infof("\ntailing boot Job pod %s\n\n", info(podName))
logger.Logger().Infof("\ntailing boot Job pod %s created %s\n\n", info(podName), info(pod.CreationTimestamp))

err = podlogs.TailLogs(ns, podName, containerName, o.ErrOut, o.Out)
if err != nil {
Expand Down

0 comments on commit f72f951

Please sign in to comment.