gsutil on windows randomly fails

We are running gsutil command on windows-latest github action.
Exactly the same command sometimes runs correctly and sometimes fails with error “##[error]Process completed with exit code 1.”

gsutil cp release/*.exe "gs://$env:UPLOADER_RELEASE_BUCKET/$env:VERSION-$env:GIT_HASH/"

We checked everything, the problem does no seem to be in our code. Below are 2 examples: success and failure. Any help is very much appreciated.

just for the information, the same command always runs successfully on parallel linux build.

Hi @vohtaski ,

  1. Please try to preface  gsutil   with  call , please refer to the link here and here for the details.

  2. The default shell for windows runner is ‘pwsh’, since the command works fine on linux, you can also try to specify ‘shell: bash’ for the step.

And it’s recommended to enable debug logging to check for more error details. If the issue persists, please kindly share your repo/sample repo for further investigation.

Thanks.

Thank you!

I tried call with no luck.

I also tried ‘shell: bash’, but it did not find gsutil, looks like for windows distribution there is no gsutil bash version. There are gcloud bash, gcloud.cmd and gsutil.cmd.

In the end I switched to use gsutil rsync that works reliably. Still no idea why gsutil cp is mis-behaving.

Thank you for the debug logging hint. Was not aware of it.

Hi @vohtaski ,

Thanks for your reply! Glad to know it’s resolved with command ‘gsutil rsync’ :).

Since it’s randomly failed on the windows runner, i believe the gsutil should exist.

I checked with below code, looks it’s ’ C:\Program Files\google-cloud-sdk\bin\gsutil.cmd’ on my side. If it’s not the correct one, i think should check the app installed and path setting then.

jobs:
  Build:
    runs-on: windows-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: setup google cloud SDK
        uses: mathrix-education/setup-gcloud@master
      - name: check gsutil
        run: |
          where gsutil
        shell: cmd

gsutil.png

You can check the gsutil for your runner as well, and use ‘full path gsutil cp’ with shell: bash for a try. code sample as below:

- run: C:\Program Files\google-cloud-sdk\bin\gsutil.....
        shell: bash

Thanks.

I am using this action:

jobs:
  release-win-to-gcs:
    name: Release Win to GCP

    runs-on: windows-latest

    steps:
      - name: Setup gcloud CLI for Dev
        uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
        with:
          version: 'latest'
          project_id: ${{ env.PROJECT_ID }}
          service_account_email: ${{ env.SERVICE_ACCOUNT_EMAIL }}
          service_account_key: ${{ secrets.PROD_GITHUB_CI_CD_SA_KEY}}
      - run: gcloud info
      - run: gsutil

Thanks @vohtaski !