Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't enable pullRequest mode using jenkins job DSL #154

Open
bouncysteve opened this issue Feb 22, 2024 · 2 comments
Open

Can't enable pullRequest mode using jenkins job DSL #154

bouncysteve opened this issue Feb 22, 2024 · 2 comments
Labels

Comments

@bouncysteve
Copy link

Jenkins and plugins versions report

Environment
Jenkins: 2.324
OS: Linux - 3.10.0-1160.49.1.el7.x86_64
Java: 1.8.0_312 - Red Hat, Inc. (OpenJDK 64-Bit Server VM)
---
SquishPlugin:8.1.0
TestComplete:2.8.1
ace-editor:1.1
active-directory:2.25
ant:1.13
antisamy-markup-formatter:2.5
apache-httpcomponents-client-4-api:4.5.13-1.0
artifactory:3.14.2
audit-trail:3.10
authentication-tokens:1.4
authorize-project:1.4.0
aws-java-sdk:1.12.101-300.vc09c7be9cb57
aws-java-sdk-cloudformation:1.12.101-300.vc09c7be9cb57
aws-java-sdk-codebuild:1.12.101-300.vc09c7be9cb57
aws-java-sdk-ec2:1.12.101-300.vc09c7be9cb57
aws-java-sdk-ecr:1.12.101-300.vc09c7be9cb57
aws-java-sdk-ecs:1.12.101-300.vc09c7be9cb57
aws-java-sdk-elasticbeanstalk:1.12.101-300.vc09c7be9cb57
aws-java-sdk-iam:1.12.101-300.vc09c7be9cb57
aws-java-sdk-logs:1.12.101-300.vc09c7be9cb57
aws-java-sdk-minimal:1.12.101-300.vc09c7be9cb57
aws-java-sdk-ssm:1.12.101-300.vc09c7be9cb57
backup:1.6.1
blueocean:1.25.2
blueocean-autofavorite:1.2.4
blueocean-bitbucket-pipeline:1.25.2
blueocean-commons:1.25.2
blueocean-config:1.25.2
blueocean-core-js:1.25.2
blueocean-dashboard:1.25.2
blueocean-display-url:2.4.1
blueocean-events:1.25.2
blueocean-git-pipeline:1.25.2
blueocean-github-pipeline:1.25.2
blueocean-i18n:1.25.2
blueocean-jira:1.25.2
blueocean-jwt:1.25.2
blueocean-personalization:1.25.2
blueocean-pipeline-api-impl:1.25.2
blueocean-pipeline-editor:1.25.2
blueocean-pipeline-scm-api:1.25.2
blueocean-rest:1.25.2
blueocean-rest-impl:1.25.2
blueocean-web:1.25.2
bootstrap4-api:4.6.0-3
bootstrap5-api:5.1.3-3
bouncycastle-api:2.25
branch-api:2.7.0
build-blocker-plugin:1.7.8
build-failure-analyzer:2.1.0
build-monitor-plugin:1.13+build.202112061615
build-timeout:1.20
caffeine-api:2.9.2-29.v717aac953ff3
checks-api:1.7.2
chucknorris:1.4
claim:2.18.2
cloud-stats:0.27
cloudbees-bitbucket-branch-source:734.v2f848c5e6ea2
cloudbees-credentials:3.3
cloudbees-folder:6.16
cobertura:1.17
code-coverage-api:2.0.4
codesonar:2.1.0
command-launcher:1.6
conditional-buildstep:1.4.1
config-file-provider:3.8.2
copyartifact:1.46.2
credentials:2.6.2
credentials-binding:1.27
cucumber-reports:5.6.1
dashboard-view:2.18
data-tables-api:1.11.3-4
dependency-check-jenkins-plugin:5.1.2
dependency-track:4.0.0
digitalocean-plugin:1.3.0
discard-old-build:1.05
display-url-api:2.3.5
docker-commons:1.17
docker-workflow:1.26
dtkit-api:3.0.0
durable-task:493.v195aefbb0ff2
ec2-deployment-dashboard:1.0.10
echarts-api:5.2.2-1
envinject:2.4.0
envinject-api:1.8
extended-read-permission:3.2
external-monitor-job:1.7
favorite:2.3.3
file-operations:1.7
filesystem_scm:2.1
font-awesome-api:5.15.4-4
forensics-api:1.7.0
gerrit-trigger:2.35.2
git:4.10.1
git-client:3.10.0
git-server:1.10
github:1.34.1
github-api:1.301-378.v9807bd746da5
github-branch-source:2.11.3
gradle:1.37.1
greenballs:1.15.1
handlebars:3.0.8
handy-uri-templates-2-api:2.1.8-1.0
heavy-job:1.1
htmlpublisher:1.28
hudson-pview-plugin:1.8
ivy:2.1
jackson2-api:2.13.0-230.v59243c64b0a5
javadoc:1.6
jaxb:2.3.0.1
jdk-tool:1.5
jenkins-design-language:1.25.2
jira:3.6
jjwt-api:0.11.2-9.c8b45b8bb173
job-dsl:1.78.1
jobConfigHistory:2.28.1
jquery:1.12.4-1
jquery-detached:1.2.1
jquery3-api:3.6.0-2
jsch:0.1.55.2
junit:1.53
ldap:2.7
lockable-resources:2.12
mailer:1.34
mashup-portlets-plugin:1.1.2
matrix-auth:2.6.11
matrix-project:772.v494f19991984
maven-plugin:3.15.1
mercurial:2.16
metrics:4.0.2.8
momentjs:1.1.1
msbuild:1.30
mstest:1.0.0
mstestrunner:1.3.0
naginator:1.18.1
nexus-task-runner:0.9.2
nuget:1.1
okhttp-api:4.9.3-105.vb96869f8ac3a
osf-builder-suite-standalone-sonar-linter:1.0.3
pam-auth:1.6.1
parameterized-trigger:2.42
pipeline-build-step:2.15
pipeline-graph-analysis:1.12
pipeline-input-step:427.va6441fa17010
pipeline-milestone-step:1.3.2
pipeline-model-api:1.9.3
pipeline-model-definition:1.9.3
pipeline-model-extensions:1.9.3
pipeline-rest-api:2.19
pipeline-stage-step:2.5
pipeline-stage-tags-metadata:1.9.3
pipeline-stage-view:2.19
plain-credentials:1.7
plugin-util-api:2.6.0
popper-api:1.16.1-2
popper2-api:2.10.2-1
postbuildscript:3.0.0
powershell:1.3
project-build-times:1.2.1
promoted-builds:3.11
pubsub-light:1.16
quality-gates:2.5
resource-disposer:0.20
run-condition:1.5
s3:0.12.1
scm-api:2.6.5
script-security:1138.v8e727069a_025
snakeyaml-api:1.29.1
sonar:2.14
sonar-gerrit:385.v890738eeff15
sonar-quality-gates:1.3.1
sonargraph-integration:5.0.1
sse-gateway:1.24
ssh-credentials:1.19
sshd:3.1.0
structs:324.va_f5d6774f3a_d
support-core:2.79
swarm:3.29
test-results-analyzer:0.3.5
test-stability:2.3
testabilityexplorer:0.4
text-finder:1.17
text-finder-run-condition:0.1
thinBackup:1.10
throttle-concurrents:2.5
timestamper:1.15
token-macro:267.vcdaea6462991
trilead-api:1.0.13
variant:1.4
view-job-filters:2.3
vstestrunner:1.0.8
windows-exe-runner:1.2
windows-slaves:1.8
workflow-aggregator:2.6
workflow-api:1105.v3de5e2efac97
workflow-basic-steps:2.24
workflow-cps:2640.v00e79c8113de
workflow-cps-global-lib:552.vd9cc05b8a2e1
workflow-durable-task-step:1102.v9c8d2f466adb
workflow-job:2.42
workflow-multibranch:2.26
workflow-scm-step:2.13
workflow-step-api:613.v375732a042b1
workflow-support:3.8
ws-cleanup:0.43
xml-job-to-job-dsl:0.1.13
xunit:3.0.5

What Operating System are you using (both controller, and any agents involved in the problem)?

Controller: CentOS Linux release 7.9.2009 (Core)
Agents: Windows Server 2016

Reproduction steps

Supply job dsl for gerrit job, intending pullRequest mode to be used with default settings:
($sonarScanArguments below =

/d:sonar.pullrequest.key=${GERRIT_CHANGE_NUMBER}-${GERRIT_PATCHSET_NUMBER}
/d:sonar.pullrequest.base=${GERRIT_BRANCH}
/d:sonar.pullrequest.branch=${GERRIT_REFSPEC}
)

...

wrappers {
withSonarQubeEnv {
installationName('GTS Sonar')
}
timestamps()
preBuildCleanup()
}

...

steps {
msBuildSQRunnerBegin {
additionalArguments("/d:sonar.projectBaseDir=${WORKSPACE} ${sonarScanArguments}")
projectKey(jenkinsProject.sonarProjectKey)
projectName('AWSInterface')
projectVersion('${JOB_NAME}')
}

...

msBuildSQRunnerEnd()

...

}

...

publishers {
if (jenkinsProject.gerritJob){
sonarToGerrit {
inspectionConfig {
analysisStrategy {
pullRequest()
}
}
}
}
}

Expected Results

Job to include sonar-gerrit as a publisher, using pullRequest mode.

Actual Results

config.xml shows analysisStrategy is preview mode:

    <org.jenkinsci.plugins.sonargerrit.SonarToGerritPublisher plugin="sonar-gerrit@385.v890738eeff15">
    <inspectionConfig>
        <analysisStrategy class="org.jenkinsci.plugins.sonargerrit.sonar.preview_mode_analysis.PreviewModeAnalysisStrategy">
            <baseConfig>
                <projectPath/>
                <sonarReportPath>target/sonar/sonar-report.json</sonarReportPath>
                <autoMatch>false</autoMatch>
            </baseConfig>

...

Anything else?

I am using the withSonarQubeEnv wrapper, specifying the installation name, which is needed for a separate step I have which uses the ${SONAR_AUTH_TOKEN} and ${SONAR_HOST_URL} environment variables to make an API request to query the quality gate status. Removing the wrapper and the step which depends on it has no effect on the sonar-gerrit config.

Are you interested in contributing a fix?

No response

@reda-alaoui
Copy link
Contributor

The Readme specifies:

sonarToGerrit(
        inspectionConfig: [
                analysisStrategy: pullRequest()
        ]
)

This is not what your configuration looks like. You used { instead of [ for inspectionConfig.

@reda-alaoui reda-alaoui closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2024
@bouncysteve
Copy link
Author

The examples in the readme are for pipeline DSL, not job DSL.

The dynamic job DSL is well-formed (is processed by the seed job), but does not have the expected result.

@reda-alaoui reda-alaoui reopened this Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants