Variable for kubernetesServiceEndpoint in Kubectl task can handle only Global Variables
See original GitHub issueRequired Information
Entering this information will route you directly to the right team and expedite traction.
Question, Bug, or Feature?
Type: Bug
Enter Task Name: Kubectl task
list here (V# not needed):
https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks
Environment
- Server - Azure Pipelines
- Agent - Private:
Issue Description
Variable for kubernetesServiceEndpoint in Kubectl task can handle only Global Variables and Stage Variable are not recognized
When using kubectl task and login command the kubernetesServiceEndpoint accepts only the Global Variable
When setting the variable inside stage the kubectl task login
complains it can’t find the resource.
Service endpoint is private and security is set to all pipelines
when echoing the variable is reflected
KubeTest
this is how variable is set.
displayName: Deploy to Test
variables:
- name: k8sNamespace
value: wso2is
- name: k8sReleaseName
value: test
- name: k8sService
value: KubeTest
- group: test-wso2is
jobs:
this is how is used:
- task: Kubernetes@1
displayName: Login to Kubernetes
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceEndpoint: $(k8sService)
command: login
Task logs
N/A
Troubleshooting
When setting the variable in the global variables, deployment stage accept it and can work with variable. When hardcoding the Kubernetes endpoint also everything works fine.
Error logs
Error message appears even before any stage starts.
There was a resource authorization issue: "The pipeline is not valid. Job DeployTest: Step input kubernetesServiceEndpoint references service connection $(k8sService) which could not be found. The service connection does not exist or has not been authorized for use. For authorization details, refer to https://aka.ms/yamlauthz."```
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:9 (2 by maintainers)
I saw this somewhere which works for me:
{{ variables.k8sService }}
instead of$(k8sService)
I had more days to test everything. And come to this: If I declare the variable in the global section and then redeclare it in the staging section, then everything works fine. And this does not happen with other variables.