Documentation
¶
Overview ¶
Package jobssh finds the ssh command for jobs rerun with SSH enabled.
A job rerun with SSH gets an "Enable SSH" step (v3 step type enable_ssh) once it starts. The step runs in the background for the life of the job, and its output names the command to connect, e.g.
You can now SSH into this job if your SSH public key is added:
$ ssh b0023961-07d3-4943-8342-a052e5e9307a-0@ssh.circleci.com
Older jobs print the host and port form instead (ssh -p 54782 3.94.12.34); both are read the same way. A parallel job has one such step, and one command, per execution.
Index ¶
Constants ¶
const StepType = "enable_ssh"
StepType is the v3 step type of the step that enables SSH on a job.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
Job string // job name
JobID uuid.UUID // the rerun job's ID
Execution int // parallel execution index
Executions int // number of parallel executions the job has
Command string // the ssh command, as the job printed it
User string // user part of the destination, if any
Host string
Port int // 0 when the command names no port
}
Conn is how to connect to one execution of a job.
func ParseOutput ¶
ParseOutput reads the ssh command from an SSH step's output. ok is false when the output does not hold one yet.
func Wait ¶
func Wait(ctx context.Context, client *apiclient.Client, workflowID uuid.UUID, names []string, opts Options) ([]Conn, error)
Wait polls the rerun workflow until each named job prints its ssh command, and returns the commands in the order of names, then execution. Commands found before an error are returned with it.
type NoSSHError ¶
NoSSHError means a job ended without printing an ssh command, so there is nothing to connect to.
func (*NoSSHError) Error ¶
func (e *NoSSHError) Error() string
type Options ¶
type Options struct {
// Timeout bounds the whole wait.
Timeout time.Duration
// Interval is the time between polls.
Interval time.Duration
// OnStatus is called when what Wait is waiting for changes, with a short
// description such as "Waiting for build to start".
OnStatus func(string)
// OnConn is called for each command as soon as it is found.
OnConn func(Conn)
}
Options control Wait.
type TimeoutError ¶
TimeoutError means the wait ran out of time. Pending names the jobs that still had no command.
func (*TimeoutError) Error ¶
func (e *TimeoutError) Error() string