Azure 构建代理

Azure build Agent

情况: 在 azure 管道的构建过程中,我在自托管代理上使用 JavaToolInstaller 并将“java/JAVA_HOME_8_x64_”放在目录
背景: 当我对该目录应用完全权限并为构建过程创建它时,我认为这不是权限问题
评估:有没有人以前见过这个问题?

重现步骤-主持现场代理

JavaToolInstaller

- task: JavaToolInstaller@0
  inputs:
    versionSpec: '8'
    jdkArchitectureOption: 'x64'
    jdkSourceOption: 'LocalDirectory'
    jdkFile: '/opt/jdk-8u251-linux-x64.tar.gz'
    jdkDestinationDirectory: '/opt/java'
    cleanDestinationDirectory: true
  condition: eq( variables['Agent.OS'], 'Linux' )

构建时出错

Cleaning destination folder before extraction: /opt/java
Retrieving the JDK from local path.
##[warning]Can\'t find loc string for key: ExtractingArchiveToPath
ExtractingArchiveToPath /opt/java/JAVA_HOME_8_x64_jdk-8u251-linux-x64_tar.gz
Creating destination folder: /opt/java/JAVA_HOME_8_x64_jdk-8u251-linux-x64_tar.gz
##[error]Unable to create directory '/opt/java/JAVA_HOME_8_x64_jdk-8u251-linux-x64_tar.gz'. EACCES: permission denied, mkdir '/opt/java/JAVA_HOME_8_x64_jdk-8u251-linux-x64_tar.gz'
##[error]Unable to create directory '/opt/java/JAVA_HOME_8_x64_jdk-8u251-linux-x64_tar.gz'. EACCES: permission denied, mkdir '/opt/java/JAVA_HOME_8_x64_jdk-8u251-linux-x64_tar.gz'
Finishing: JavaToolInstaller

根据错误信息,您似乎没有写入该文件的权限。请检查并确保您对该文件夹具有 w 和 r 权限

步骤:

在图标上找到文件jdk-8u251-linux-x64.tar.gz->right-click->select属性->点击标签权限然后检查帐户权限

或者使用命令ls –l {file name}检查文件夹权限,然后运行命令chmod [permission] [file_name]更新权限

请参阅此link了解更多详情:How to change directory permissions in Linux