the server doesn't have a resource type "deployment" in jenkins

9/14/2020

In my jenkins pipeline, I've configured like that one.

	stage('Deploying into k8s'){
		steps{
			sh 'kubectl set image deployment/my-api my-api=ppshein/myapi:${BUILD_NUMBER} -n my-ns --record'
		}
	}

and when I've run Jenkins pipeline, I've encountered following error message:

error: the server doesn't have a resource type "deployment"

But when I ssh to my EC2 instance and run same command, it was working successfully.

Please let me know I missed something to configure in Jenkins or somehow user authentication in my server?

-- PPShein
amazon-eks
jenkins
kubernetes

1 Answer

1/7/2022

User Jenkins' home directory must have .kube/config,for example /var/lib/jenkins/.kube/config

-- liang gao
Source: StackOverflow