0

I have been trying to deploy my app engine app from azure pipeline now.

I was able to make mvn clean and package it but when i used mvn appengine:deploy it does throw this permission issue. I got through some common questions like this:

I cant init Google Cloud SDK on Ubuntu

and

gcloud components update permission denied

What I did, I added the script tag before my maven in yml file.

- script: |
    sudo chown -R $USER /home/vsts/.config/gcloud/config_sentinel

- task: Maven@3
  displayName: 'Maven api/pom.xml'
  inputs:
    mavenPomFile: 'api/pom.xml'
    goals: 'clean package appengine:deploy'

But not sure what is the issue and which else permission i need to set my USER for pipeline is vsts here. Please let me know if i made any mistake so far.

Error log from the pipeline is below for reference:

Downloaded from central: https://repo.maven.apache.org/maven2/com/google/guava/guava/27.0-jre/guava-27.0-jre.jar (2.7 MB at 3.4 MB/s)
Nov 06, 2019 6:51:59 PM com.google.cloud.tools.managedcloudsdk.install.Downloader download
INFO: Downloading https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.tar.gz to /home/vsts/.cache/google-cloud-tools-java/managed-cloud-sdk/downloads/google-cloud-sdk.tar.gz
Welcome to the Google Cloud SDK!
WARNING: Could not setup log file in /home/vsts/.config/gcloud/logs, (IOError: [Errno 13] Permission denied: u'/home/vsts/.config/gcloud/logs/2019.11.06/18.52.02.245238.log')
Traceback (most recent call last):
  File "/home/vsts/.cache/google-cloud-tools-java/managed-cloud-sdk/LATEST/google-cloud-sdk/bin/bootstrapping/install.py", line 225, in <module>
    main()
  File "/home/vsts/.cache/google-cloud-tools-java/managed-cloud-sdk/LATEST/google-cloud-sdk/bin/bootstrapping/install.py", line 200, in main
    Prompts(pargs.usage_reporting)
  File "/home/vsts/.cache/google-cloud-tools-java/managed-cloud-sdk/LATEST/google-cloud-sdk/bin/bootstrapping/install.py", line 123, in Prompts
    scope=properties.Scope.INSTALLATION)
  File "/home/vsts/.cache/google-cloud-tools-java/managed-cloud-sdk/LATEST/google-cloud-sdk/lib/googlecloudsdk/core/properties.py", line 2269, in PersistProperty
    named_configs.ActivePropertiesFile.Invalidate(mark_changed=True)
  File "/home/vsts/.cache/google-cloud-tools-java/managed-cloud-sdk/LATEST/google-cloud-sdk/lib/googlecloudsdk/core/configurations/named_configs.py", line 413, in Invalidate
    file_utils.WriteFileContents(config.Paths().config_sentinel_file, '')
  File "/home/vsts/.cache/google-cloud-tools-java/managed-cloud-sdk/LATEST/google-cloud-sdk/lib/googlecloudsdk/core/util/files.py", line 1103, in WriteFileContents
    with FileWriter(path, private=private) as f:
  File "/home/vsts/.cache/google-cloud-tools-java/managed-cloud-sdk/LATEST/google-cloud-sdk/lib/googlecloudsdk/core/util/files.py", line 1180, in FileWriter
    return _FileOpener(path, mode, 'write', encoding='utf8', private=private)
  File "/home/vsts/.cache/google-cloud-tools-java/managed-cloud-sdk/LATEST/google-cloud-sdk/lib/googlecloudsdk/core/util/files.py", line 1208, in _FileOpener
    raise exc_type('Unable to {0} file [{1}]: {2}'.format(verb, path, e))
googlecloudsdk.core.util.files.Error: Unable to write file [/home/vsts/.config/gcloud/config_sentinel]: [Errno 13] Permission denied: '/home/vsts/.config/gcloud/config_sentinel'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.958 s
[INFO] Finished at: 2019-11-06T18:52:02Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.google.cloud.tools:appengine-maven-plugin:2.0.0:deploy (default-cli) on project configuration-api: Execution default-cli of goal com.google.cloud.tools:appengine-maven-plugin:2.0.0:deploy failed: com.google.cloud.tools.managedcloudsdk.command.CommandExitException: Process failed with exit code: 1 -> [Help 1]
Indrajeet Gour
  • 4,020
  • 5
  • 43
  • 70
  • Using the hosted agent – Indrajeet Gour Nov 07 '19 at 08:09
  • Are you still getting this error, or did the added script solved it for you? Also, comparing the posts you shared, I noticed it is recommended to change ownership for the whole `.config/gcloud/` directory. I understand the stack trace says it is not being able to write to `config_sentinel` specifically, but might be worth the try. – pessolato Nov 08 '19 at 08:54
  • Yes, I was able to solve it via: adding the script in azure ops pipeline before the deployment command which looks like this. "sudo chown -R $USER:$USER /home/vsts/.config/gcloud/" Also i has many other issues, due to this it messed up a lot. – Indrajeet Gour Nov 08 '19 at 11:30
  • So it was the permissions for the `.config/gcloud` directory it self! I looked in opened issues of Google's [Issue Tracker](https://issuetracker.google.com/issues), but could not find anything confirming this to be a bug, only people having issues with their Cloud SDK installation. So if you have any other particular issue with that, I suggest you open a ticket there. Also since the new script fixed it, could you post it as an answer, for community purposes? I'll be sure to upvote it once you do. – pessolato Nov 08 '19 at 14:57
  • @Indrajeet Gour Thanks for sharing your solution here.Could you convert your comment into an answer.This will benefit users who have the same problem and we could archive this thread, thanks. Have a good day. – Hugh Lin Nov 13 '19 at 07:18

1 Answers1

1

As requested, posting my yaml file which may help few to solve the same problem.

Now I given the permission to the parent directory which is gcloud one, as I shown other directories were giving issue.

- script: |
   sudo chown -R $USER:$USER /home/$USER/.config/gcloud/

- task: Maven@3
  displayName: 'Maven api/pom.xml'
  inputs:
    mavenPomFile: 'api/pom.xml'
    goals: 'clean package appengine:deploy'

I uses $USER to make it for all. As I used Azure maintained Agent my pipeline user was vsts which picked up automatically. And would help others irrespective of their user.

if any more help required let me know thanks.

Indrajeet Gour
  • 4,020
  • 5
  • 43
  • 70