protected String getFullImageName()

in src/main/java/com/microsoft/jenkins/appservice/commands/DockerCommand.java [21:53]


    protected String getFullImageName(final DockerBuildInfo dockerBuildInfo) throws AzureCloudException {
        if (StringUtils.isNotBlank(dockerBuildInfo.getDockerImage())) {
            return dockerBuildInfo.getDockerImage();
        }

        final String linuxFxVersion = dockerBuildInfo.getLinuxFxVersion();
        if (!linuxFxVersion.startsWith("DOCKER|")) {
            throw new AzureCloudException("unrecognized docker container");
        }
        // the linuxFxVersion should be "DOCKER|<registry>/repo:tag"
        // <registry>/repo:tag
        final String originalImageName = linuxFxVersion.substring(linuxFxVersion.indexOf("|") + 1).toLowerCase();

        final String newRegistry = getRegistryHostname(dockerBuildInfo.getAuthConfig().getRegistryAddress());
        final StringBuilder stringBuilder = new StringBuilder();
        if (!newRegistry.contains("index.docker.io")) {
            // append the registry host as part of the image name, it's required for non-dockerHub registry
            stringBuilder.append(newRegistry).append("/");
        }
        // append user name
        stringBuilder.append(dockerBuildInfo.getAuthConfig().getUsername()).append("/");
        // append the original repo part after username
        final NameParser.ReposTag reposTag = NameParser.parseRepositoryTag(originalImageName);
        final String imageNameWithoutTagAndRegistry = NameParser.resolveRepositoryName(reposTag.repos).reposName;
        final String[] nameParts = imageNameWithoutTagAndRegistry.split("/", 2);
        if (nameParts.length == 1) {
            stringBuilder.append(imageNameWithoutTagAndRegistry);
        } else {
            stringBuilder.append(nameParts[1]);
        }

        return stringBuilder.toString();
    }