Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'gcloud' is not recognized as a command #67

Open
TMGMike opened this issue Jul 18, 2022 · 5 comments
Open

'gcloud' is not recognized as a command #67

TMGMike opened this issue Jul 18, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@TMGMike
Copy link

TMGMike commented Jul 18, 2022

Hi guys,

I've been using this tool to install the Google Cloud SDK on my agent machines in Azure Pipelines, and haven't noticed any issues until recently (although I took a break for a little while so there was no activity).

Installing the SDK succeeds, but when trying to authenticate with GCP (to upload build artefacts to GCS), it fails to find the command. The log shows that it has added the script to the PATH variable, so it shouldn't be failing... Unless a recent upgrade to the windows agents has caused the machine to require a reboot or something?

This is how I'm installing the SDK:

- task: GoogleCloudSdkTool@1
  displayName: 'Install GCP SDK'
  inputs:
    versionSpec: '393.x' # '315.x'

This is how I'm then authenticating (to be used when uploading the artefacts):

- task: CmdLine@2
  displayName: 'Authenticate GCP'
  inputs:
    script: 'gcloud auth activate-service-account $(serviceAccount) --key-file=$(GcpKeyFile.secureFilePath) --project=[...]'

'gcloud' is not recognized as an internal or external command, operable program or batch file.
##[error]Cmd.exe exited with code '1'.
Finishing: Authenticate GCP

Any ideas? Did I miss a big change during my break?

Edit: I'm also noticing that no matter what version I specify in the versionSpec attribute, it always seems to install 392... Downloading: https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-392.0.0-windows-x86_64.zip - is this normal?

@TMGMike
Copy link
Author

TMGMike commented Aug 2, 2022

Any updates on this?

For now, I've had to create a variable manually pointing to the SDK location (e.g. C:\hostedtoolcache\windows\gcloud\395.0.0\x64\bin) - which isn't great long term because I'd have to keep modifying this every time it fails because of a new SDK version (since the versionSpec attribute does nothing at all)

FWIW, it seems the install command is appending the PATH variable as: C:\hostedtoolcache\windows\gcloud\395.0.0\x64 - this is missing the \bin directory - or at least this is what's being printed. But if this is true, it makes me wonder how this ever worked previously?

@TMGMike
Copy link
Author

TMGMike commented Oct 2, 2022

@gcacars Hi, any chance you could take a look at this? Have you seen/heard similar issues?

My temporary workaround is already facing issues, because I have a schedule set up for a weekly build, and has already failed so many times because the SDK version changes, so I have to manually commit the new path every time it fails.

It would be really nice to get this working again.

@gcacars
Copy link
Member

gcacars commented Nov 19, 2022

Hi @TMGMike sorry for the long time without a reply.
I'm really busy at home, work and personal projects, and I'm not able to give the necessary attention to this tool, unfortunately.
Is in my plans, but I don't have time for now.

I really appreciate any help from community in this. If you can, please open a PR.
Also, to develop and test new features/fixes, there are some costs, and a big problem with the size limit of package (main reason to not have new updates).

This is a one file task code:
https://github.com/nexsolab/azure-devops-google-cloud-tools/blob/master/Tasks/GoogleCloudSdkTool/gcloudcli.ts

Inspired by official Azure CLI task:
https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/AzureCLIV1/azureclitask.ts

@gcacars gcacars added the bug Something isn't working label Nov 19, 2022
@TMGMike
Copy link
Author

TMGMike commented Dec 4, 2022

Hi @TMGMike sorry for the long time without a reply. I'm really busy at home, work and personal projects, and I'm not able to give the necessary attention to this tool, unfortunately. Is in my plans, but I don't have time for now.

I really appreciate any help from community in this. If you can, please open a PR. Also, to develop and test new features/fixes, there are some costs, and a big problem with the size limit of package (main reason to not have new updates).

This is a one file task code: https://github.com/nexsolab/azure-devops-google-cloud-tools/blob/master/Tasks/GoogleCloudSdkTool/gcloudcli.ts

Inspired by official Azure CLI task: https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/AzureCLIV1/azureclitask.ts

@gcacars Hi, no worries on the reply, I've been super busy myself so I understand :)

I can try to raise a PR to fix this, if I can find some time myself. If it turns out it is just the fact that we're missing the \bin part of the path, it should be a simple fix.

@TMGMike
Copy link
Author

TMGMike commented Dec 4, 2022

@gcacars Just taking a look into the code, I see an explicit if statement to not append \bin if the OS is Windows - before I go removing this, was there a reason for this?

if (osPlat != 'win32') {
toolPath = path.join(toolPath, 'bin');
}

Did Google change their folder structure for Windows builds, or is there another reason?

Also while we're here, do you know why the versionSpec field doesn't do anything? Even when I specify a GCP SDK version, it will still always install the newest release... is it failing to find the version specified or something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants