redhat-developer / openshift-vsts

OpenShift Extension for Azure DevOps.
Apache License 2.0
15 stars 20 forks source link

oc.exe not found with windows agent #193

Closed safari137 closed 2 years ago

safari137 commented 2 years ago

I'm using a windows agent in Azure Devops. the oc-setup task successfully downloads the oc.zip file and unzips it correctly as oc.exe. However, when it caches the file in _tool\oc\3.11.x\x64\ it is named plain ol 'oc' with out the .exe extension.

That results in me getting this error in the oc-cmd task: ##[error]Unable to locate executable file: 'C:\Users\my-user-name\agent\_work\_tool\oc\3.11.0\x64\oc.exe'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.

If I rename the file to oc.exe, everything works as expected. The plan is to to deploy the agent as a container, so that fix is not ideal since it will be lost any time the container is re-deployed.

I am currently working around it with the following pipelines template:

        - checkout: self
        #(rename oc to oc.exe)        
        - powershell: | 
            Get-ChildItem -Path ..\..\_tool\ -filter oc -recurse -ErrorAction SilentlyContinue -Force | Where-Object{  $_.Mode -match 'a' }
            if ($files.length -gt 0) {
                mv $files[0].VersionInfo.FileName "$($files[0].VersionInfo.FileName).exe"              
            }
        - task: oc-setup@2
          inputs:
            connectionType: 'OpenShift Connection Service'
            openshiftService: 'openshift-test'
            version: '3.11.0'
        #(rename oc to oc.exe)        
        - powershell: | 
            $files = Get-ChildItem -Path ..\..\_tool\ -filter oc -recurse -ErrorAction SilentlyContinue -Force | Where-Object{  $_.Mode -match 'a' }
            if ($files.length -gt 0) {
                mv $files[0].VersionInfo.FileName "$($files[0].VersionInfo.FileName).exe"              
            }
        - powershell: |
            oc -n ${{ parameters.oc_namespace }} process -f ${{ variables.oc_yaml_file }} `
            APP_NAME=${{ parameters.appName }} `
            IMAGE_VERSION=${{ parameters.version }} `
            OC_NAMESPACE=${{ parameters.oc_namespace }} | oc apply -f -

I have the rename in there twice in case it is already cached.

Am I doing something wrong or is this a bug?

lstocchi commented 2 years ago

Hi @safari137 , thanks for letting us know about it and sorry for the late response. I'll give this a look as it seems to be a bug. I'll let you know asap