Skip to content

Commit da6bd1d

Browse files
Merge pull request #1056 from renyunkang/agent-info
fix: pod name couldn't be empty
2 parents b2263fa + 07f8859 commit da6bd1d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

controllers/jenkins/pipelinerun/pipelinerun_controller.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,16 @@ func (r *Reconciler) getAgentInfo(ctx context.Context, pr *v1alpha3.PipelineRun)
268268
if strings.HasPrefix(line, "Agent") && strings.Contains(line, "is provisioned from template") {
269269
parts := strings.Fields(line)
270270
if len(parts) > 2 {
271-
pr.Annotations[v1alpha3.JenkinsAgentPodNameAnnoKey] = parts[1]
271+
podName = parts[1]
272+
pr.Annotations[v1alpha3.JenkinsAgentPodNameAnnoKey] = podName
272273
klog.Infof("get agent pod name: %s", parts[1])
273274
}
274275
break
275276
}
276277
}
277278
}
278279

279-
if !nodeNameExist {
280+
if podName != "" && !nodeNameExist {
280281
agentPod := &corev1.Pod{}
281282
err := r.Client.Get(ctx, client.ObjectKey{Namespace: r.Options.WorkerNamespace, Name: podName}, agentPod)
282283
if err != nil {

0 commit comments

Comments
 (0)