Search code examples
javalinuxazure-pipelines-build-taskazure-devops-self-hosted-agentazure-pipelines-tasks

Azure build Agent


Situation: During the build process of an azure pipeline i use the JavaToolInstaller on a self hosted agent and it places "java/JAVA_HOME_8_x64_" in the directory
Background: I dont believe this to be a permission issue when i have applied full permissions to that directory and created it for the build process
Assessment: Has anyone see this issue before?

Steps to reproduce - host onsite agent

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' )

Error during build

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

Solution

  • According to the error message, it seems that you do not have permission to write this file. Please check it and ensure that you have w and r permission for this folder

    Steps:

    Locate the file jdk-8u251-linux-x64.tar.gz->right-click on the icon->select Properties->click the tab permission then check the account permission

    Or use the cmd ls –l {file name} to check the folder permission, then run the cmd chmod [permission] [file_name] to update the permission

    Please refer this link for more details: How to change directory permissions in Linux