Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-75852

Add support for Alpine Linux

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • adoptopenjdk-plugin
    • None

      When I download a JDK via the plugin "Eclipse Temurin installer" to a node which has Linux Alpine as OS, I get an error when accessing the JDK that it cannot be found.

       

      This is because the downloaded JDK is based on GNU as the standard C library (gclib). Under Alpine, however, MUSL is used as the standard C library.

       

      Therefore the JDK for Alpine Linux must be downloaded from Eclipse-Temurin.

      Unfortunately, the plugin does not differentiate between Linux and Alpine Linux.

       

      In the appendix you will find my adaptations for the support of Alpine Linux. I will also write down the relevant adaptations directly here.

       
       

      /**
       * Supported platform
       */
      public enum Platform {
          LINUX("linux"),
          ALPINE_LINUX("alpine-linux"),
          WINDOWS("windows"),
          MACOS("mac"),
          SOLARIS("solaris"),
          AIX("aix");
      
      
       public static Platform current() throws DetectionFailedException {
          String arch = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
          if (arch.contains("linux")) {
              try {
                  if (isLinuxAlpineDistro()) {
                      return ALPINE_LINUX;
                  }
              } catch (IOException e) {
                  throw new DetectionFailedException(Messages.AdoptOpenJDKInstaller_Platform_unknownPlatform(arch));
              }
              return LINUX;
          }
          if (arch.contains("windows")) return WINDOWS;
          if (arch.contains("sun") || arch.contains("solaris")) return SOLARIS;
          if (arch.contains("mac")) return MACOS;
          if (arch.contains("aix")) return AIX;
          throw new DetectionFailedException(Messages.AdoptOpenJDKInstaller_Platform_unknownPlatform(arch));
      }
      
      private static boolean isLinuxAlpineDistro() throws IOException {
          final File releaseFile = new File("/etc/os-release");
          if (releaseFile.exists()) {
              try (final Stream<String> lines = Files.lines(releaseFile.toPath(), Charset.defaultCharset())) {
                  return lines.anyMatch("id=alpine"::equalsIgnoreCase);
              }
          }
          return false;
      }

       

            markewaite Mark Waite
            nischroeder Nicolas
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: