mc1arke / sonarqube-community-branch-plugin

A plugin that allows branch analysis and pull request decoration in the Community version of Sonarqube
GNU Lesser General Public License v3.0
2.24k stars 523 forks source link

docker-compose up fails with "can't find gid for group sonarqube: no such group: sonarqube" #958

Open ivanignatiev opened 2 months ago

ivanignatiev commented 2 months ago

Describe the bug

Step 7/11 : COPY --from=builder --chown=sonarqube /home/build/project/build/libs/sonarqube-community-branch-plugin-*.jar /opt/sonarqube/extensions/plugins/ unable to convert uid/gid chown string to host mapping: can't find gid for group sonarqube: no such group: sonarqube

To Reproduce Steps to reproduce the behavior:

  1. Clone this repository
  2. docker-compose up
  3. See error

Step 7/11 : COPY --from=builder --chown=sonarqube /home/build/project/build/libs/sonarqube-community-branch-plugin-*.jar /opt/sonarqube/extensions/plugins/ unable to convert uid/gid chown string to host mapping: can't find gid for group sonarqube: no such group: sonarqube

Expected behavior

SonarQube Community Edition running with plugin.

Screenshots

Logs:

docker-compose up
Building sonarqube
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            Install the buildx component to build images with BuildKit:
            https://docs.docker.com/go/buildx/

Sending build context to Docker daemon  3.167MB
Step 1/11 : ARG SONARQUBE_VERSION
Step 2/11 : FROM gradle:8.9-jdk17-jammy as builder
 ---> 7ea26a335f4a
Step 3/11 : COPY . /home/build/project
 ---> 57a1b51590b8
Step 4/11 : WORKDIR /home/build/project
 ---> Running in 1d609c78e871
Removing intermediate container 1d609c78e871
 ---> 4a5911cec8ed
Step 5/11 : RUN gradle build -x test
 ---> Running in 9fdbfdb135b8
Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :
The 'sonarqube' task depends on compile tasks. This behavior is now deprecated and will be removed in version 5.x. To avoid implicit compilation, set property 'sonar.gradle.skipCompile' to 'true' and make sure your project is compiled, before analysis has started.
The 'sonar' task depends on compile tasks. This behavior is now deprecated and will be removed in version 5.x. To avoid implicit compilation, set property 'sonar.gradle.skipCompile' to 'true' and make sure your project is compiled, before analysis has started.
Extracting SonarQube libraries (this may take a while)...

> Task :compileJava
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/azuredevops/DefaultAzureDevopsClientFactory.java:47: warning: [deprecation] configure(MapperFeature,boolean) in ObjectMapper has been deprecated
                .configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true)
                ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/PostAnalysisIssueVisitor.java:90: warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
        private final RuleType type;
                      ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/PostAnalysisIssueVisitor.java:144: warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
        public RuleType type() {
               ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/AnalysisDetails.java:37: warning: [deprecation] STATUSES in Issue has been deprecated
            Issue.STATUSES.stream().filter(s -> !Issue.STATUS_CLOSED.equals(s) && !Issue.STATUS_RESOLVED.equals(s))
                 ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/AnalysisDetails.java:37: warning: [deprecation] STATUS_CLOSED in Issue has been deprecated
            Issue.STATUSES.stream().filter(s -> !Issue.STATUS_CLOSED.equals(s) && !Issue.STATUS_RESOLVED.equals(s))
                                                      ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/AnalysisDetails.java:37: warning: [deprecation] STATUS_RESOLVED in Issue has been deprecated
            Issue.STATUSES.stream().filter(s -> !Issue.STATUS_CLOSED.equals(s) && !Issue.STATUS_RESOLVED.equals(s))
                                                                                        ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/GithubPullRequestDecorator.java:117: warning: [deprecation] Severity in org.sonar.api.rule has been deprecated
            case Severity.INFO:
                 ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/GithubPullRequestDecorator.java:119: warning: [deprecation] Severity in org.sonar.api.rule has been deprecated
            case Severity.MINOR:
                 ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/GithubPullRequestDecorator.java:120: warning: [deprecation] Severity in org.sonar.api.rule has been deprecated
            case Severity.MAJOR:
                 ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/GithubPullRequestDecorator.java:122: warning: [deprecation] Severity in org.sonar.api.rule has been deprecated
            case Severity.CRITICAL:
                 ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/GithubPullRequestDecorator.java:123: warning: [deprecation] Severity in org.sonar.api.rule has been deprecated
            case Severity.BLOCKER:
                 ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java:52: warning: [deprecation] STATUS_CLOSED in Issue has been deprecated
    private static final List<String> CLOSED_ISSUE_STATUS = Arrays.asList(Issue.STATUS_CLOSED, Issue.STATUS_RESOLVED);
                                                                               ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java:52: warning: [deprecation] STATUS_RESOLVED in Issue has been deprecated
    private static final List<String> CLOSED_ISSUE_STATUS = Arrays.asList(Issue.STATUS_CLOSED, Issue.STATUS_RESOLVED);
                                                                                                    ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java:122: warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
        Map<RuleType, Long> issueCounts = countRuleByType(analysisDetails.getIssues());
            ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java:132: warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
                .withBugCount(issueCounts.get(RuleType.BUG))
                                              ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java:133: warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
                .withBugUrl(getIssuesUrlForRuleType(analysisDetails, RuleType.BUG))
                                                                     ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java:135: warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
                .withCodeSmellCount(issueCounts.get(RuleType.CODE_SMELL))
                                                    ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java:136: warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
                .withCodeSmellUrl(getIssuesUrlForRuleType(analysisDetails, RuleType.CODE_SMELL))
                                                                           ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java:155: warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
                .withSecurityHotspotCount(issueCounts.get(RuleType.SECURITY_HOTSPOT))
                                                          ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java:156: warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
                .withVulnerabilityCount(issueCounts.get(RuleType.VULNERABILITY))
                                                        ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java:157: warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
                .withVulnerabilityUrl(getIssuesUrlForRuleType(analysisDetails, RuleType.VULNERABILITY))
                                                                               ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java:162: warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
    private String getIssuesUrlForRuleType(AnalysisDetails analysisDetails, RuleType ruleType) {
                                                                            ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java:187: warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
        if (issue.type() == RuleType.SECURITY_HOTSPOT) {
                            ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java:250: warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
    private static Map<RuleType, Long> countRuleByType(List<PostAnalysisIssueVisitor.ComponentIssue> issues) {
                       ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java:251: warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
        return Arrays.stream(RuleType.values()).collect(Collectors.toMap(k -> k,
                             ^
warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/PullRequestFixedIssuesIssueVisitor.java:41: warning: [deprecation] CONFIRMED in IssueStatus has been deprecated
    private static final List<IssueStatus> NON_CLOSED_ISSUE_STATUSES = List.of(IssueStatus.OPEN, IssueStatus.ACCEPTED, IssueStatus.CONFIRMED);
                                                                                                                                  ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/bitbucket/BitbucketPullRequestDecorator.java:131: warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
                .filter(i -> !(i.getIssue().type() == RuleType.SECURITY_HOTSPOT && Issue.SECURITY_HOTSPOT_RESOLUTIONS
                                                      ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/bitbucket/BitbucketPullRequestDecorator.java:131: warning: [deprecation] SECURITY_HOTSPOT_RESOLUTIONS in Issue has been deprecated
                .filter(i -> !(i.getIssue().type() == RuleType.SECURITY_HOTSPOT && Issue.SECURITY_HOTSPOT_RESOLUTIONS
                                                                                        ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/bitbucket/BitbucketPullRequestDecorator.java:133: warning: [deprecation] Severity in org.sonar.api.rule has been deprecated
                .sorted(Comparator.comparing(a -> Severity.ALL.indexOf(a.getIssue().severity())))
                                                  ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/bitbucket/BitbucketPullRequestDecorator.java:176: warning: [deprecation] Severity in org.sonar.api.rule has been deprecated
            case Severity.BLOCKER:
                 ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/bitbucket/BitbucketPullRequestDecorator.java:177: warning: [deprecation] Severity in org.sonar.api.rule has been deprecated
            case Severity.CRITICAL:
                 ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/bitbucket/BitbucketPullRequestDecorator.java:179: warning: [deprecation] Severity in org.sonar.api.rule has been deprecated
            case Severity.MAJOR:
                 ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/bitbucket/BitbucketPullRequestDecorator.java:186: warning: [deprecation] RuleType in org.sonar.api.rules has been deprecated
    private static String toBitbucketType(RuleType sonarqubeType) {
                                          ^
/home/build/project/src/main/java/com/github/mc1arke/sonarqube/plugin/classloader/ReflectiveElevatedClassLoaderFactory.java:40: warning: [removal] AccessController in java.security has been deprecated and marked for removal
                AccessController.doPrivileged((PrivilegedAction<ClassLoader>) pluginClass::getClassLoader);
                ^
36 warnings

> Task :processResources
> Task :classes
> Task :jar SKIPPED
> Task :shadowJar
> Task :assemble
> Task :check
> Task :build

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.9/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD SUCCESSFUL in 1m 48s
3 actionable tasks: 3 executed
Removing intermediate container 9fdbfdb135b8
 ---> eb9007956512
Step 6/11 : FROM sonarqube:${SONARQUBE_VERSION}
 ---> a5dcab22b29c
Step 7/11 : COPY --from=builder --chown=sonarqube:sonarqube /home/build/project/build/libs/sonarqube-community-branch-plugin-*.jar /opt/sonarqube/extensions/plugins/
unable to convert uid/gid chown string to host mapping: can't find gid for group sonarqube: no such group: sonarqube
ERROR: Service 'sonarqube' failed to build : Build failed

Software Versions SONARQUBE_VERSION=10.6-community PLUGIN_VERSION=1.22.0-SNAPSHOT

Additional context

Linux 6.5.0-1025-azure #26~22.04.1-Ubuntu SMP Thu Jul 11 22:33:04 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

mc1arke commented 1 month ago

I'm unable to replicate this (MacOs Arm, Docker 25), but the issue does make sense given the group was removed in https://github.com/SonarSource/docker-sonarqube/commit/8e556d6ac42832b1e1049a442b6cf8e3583d6330. I'll drop the assignment of the group in the chown command.

mc1arke commented 1 month ago

... and I've realised my change is wrong: the chmod should be sonarqube:0 otherwise it will attempt to use the wrong group 😞