Thanks to visit codestin.com
Credit goes to github.com

Skip to content

HttpResponseException (404) calling job.build multiple times with the same parameters. #500

@pidue

Description

@pidue

Jenkins and plugins versions report

Environment
Jenkins: 2.375.3
OS: Linux - 5.15.0-83-generic
Java: 11.0.20.1 - Ubuntu (OpenJDK 64-Bit Server VM)
---
PrioritySorter:4.1.0
ace-editor:1.1
ansicolor:1.0.2
ant:487.vd79d090d4ea_e
antisamy-markup-formatter:159.v25b_c67cd35fb_
apache-httpcomponents-client-4-api:4.5.14-150.v7a_b_9d17134a_5
authentication-tokens:1.4
aws-credentials:191.vcb_f183ce58b_9
aws-java-sdk:1.12.529-406.vdeff15e5817d
aws-java-sdk-cloudformation:1.12.529-406.vdeff15e5817d
aws-java-sdk-codebuild:1.12.529-406.vdeff15e5817d
aws-java-sdk-ec2:1.12.529-406.vdeff15e5817d
aws-java-sdk-ecr:1.12.529-406.vdeff15e5817d
aws-java-sdk-ecs:1.12.529-406.vdeff15e5817d
aws-java-sdk-efs:1.12.529-406.vdeff15e5817d
aws-java-sdk-elasticbeanstalk:1.12.529-406.vdeff15e5817d
aws-java-sdk-iam:1.12.529-406.vdeff15e5817d
aws-java-sdk-kinesis:1.12.529-406.vdeff15e5817d
aws-java-sdk-logs:1.12.529-406.vdeff15e5817d
aws-java-sdk-minimal:1.12.529-406.vdeff15e5817d
aws-java-sdk-secretsmanager:1.12.529-406.vdeff15e5817d
aws-java-sdk-sns:1.12.529-406.vdeff15e5817d
aws-java-sdk-sqs:1.12.529-406.vdeff15e5817d
aws-java-sdk-ssm:1.12.529-406.vdeff15e5817d
bootstrap4-api:4.6.0-6
bootstrap5-api:5.2.1-3
bouncycastle-api:2.29
branch-api:2.1105.v472604208c55
build-name-setter:2.2.1
build-token-root:151.va_e52fe3215fc
caffeine-api:3.1.8-133.v17b_1ff2e0599
checks-api:1.8.1
cloud-stats:302.v45b_647b_90608
cloudbees-folder:6.815.v0dd5a_cb_40e0e
command-launcher:107.v773860566e2e
commons-lang3-api:3.13.0-62.v7d18e55f51e2
commons-text-api:1.10.0-68.v0d0b_c439292b_
conditional-buildstep:1.4.3
config-file-provider:953.v0432a_802e4d2
credentials:1224.vc23ca_a_9a_2cb_0
credentials-binding:626.v8d9034b_8ea_cc
data-tables-api:1.12.1-4
display-url-api:2.200.vb_9327d658781
docker-commons:419.v8e3cd84ef49c
docker-workflow:572.v950f58993843
durable-task:523.va_a_22cf15d5e0
ec2:1609.v53b_02a_b_9e52d
echarts-api:5.4.0-1
email-ext:2.99
extended-choice-parameter:376.v2e02857547b_a_
extended-read-permission:3.2
external-monitor-job:215.v2e88e894db_f8
extra-columns:1.26
extra-tool-installers:1.2
font-awesome-api:6.2.1-1
git:5.0.2
git-client:4.3.0
git-parameter:0.9.19
git-server:99.va_0826a_b_cdfa_d
gitlab-plugin:1.7.8
google-compute-engine:4.3.16
google-oauth-plugin:1.0.11
groovy:457.v99900cb_85593
h2-api:1.4.199
handlebars:3.0.8
hetzner-cloud:84.v8acf5510fd35
instance-identity:185.v303dc7c645f9
ionicons-api:56.v1b_1c8c49374e
jackson2-api:2.15.3-363.v82c51b_de9f60
jakarta-activation-api:2.0.1-3
jakarta-mail-api:2.0.1-3
javadoc:243.vb_b_503b_b_45537
javax-activation-api:1.2.0-6
javax-mail-api:1.6.2-9
jaxb:2.3.8-1
jclouds-jenkins:2.31
jdk-tool:73.vddf737284550
jersey2-api:2.40-1
jnr-posix-api:3.1.18-1
job-restrictions:0.8
jquery:1.12.4-1
jquery-detached:1.2.1
jquery3-api:3.6.1-2
jsch:0.2.8-65.v052c39de79b_2
junit:1202.v79a_986785076
ldap:711.vb_d1a_491714dc
leastload:3.0.0
locale:226.v008e1b_58cb_b_0
lockable-resources:1131.vb_7c3d377e723
log-parser:2.3.0
mailer:457.v3f72cb_e015e5
mapdb-api:1.0.9-28.vf251ce40855d
matrix-auth:3.1.9
matrix-project:802.v8013b_40c7edc
maven-plugin:3.22
mina-sshd-api-common:2.11.0-86.v836f585d47fa_
mina-sshd-api-core:2.11.0-86.v836f585d47fa_
momentjs:1.1.1
multiple-scms:0.8
naginator:1.19.2
node-iterator-api:55.v3b_77d4032326
nodelabelparameter:1.11.0
oauth-credentials:0.646.v02b_66dc03d2e
pam-auth:1.10
parameterized-trigger:2.45
patch-parameter:1.2
pipeline-build-step:491.v1fec530da_858
pipeline-graph-analysis:202.va_d268e64deb_3
pipeline-groovy-lib:689.veec561a_dee13
pipeline-input-step:477.v339683a_8d55e
pipeline-maven:1345.va_0ef5530a_5ca_
pipeline-maven-api:1345.va_0ef5530a_5ca_
pipeline-milestone-step:111.v449306f708b_7
pipeline-model-api:2.2133.ve46a_6113dfc3
pipeline-model-definition:2.2133.ve46a_6113dfc3
pipeline-model-extensions:2.2133.ve46a_6113dfc3
pipeline-rest-api:2.34
pipeline-stage-step:305.ve96d0205c1c6
pipeline-stage-tags-metadata:2.2133.ve46a_6113dfc3
pipeline-stage-view:2.34
pipeline-utility-steps:2.16.0
plain-credentials:143.v1b_df8b_d3b_e48
plugin-util-api:2.20.0
popper-api:1.16.1-3
popper2-api:2.11.6-2
postbuildscript:3.2.0-460.va_fda_0fa_26720
resource-disposer:0.23
role-strategy:633.v836e5b_3e80a_5
run-condition:1.5
scm-api:676.v886669a_199a_a_
script-security:1269.v639888f5e366
scripted-cloud-plugin:0.12
snakeyaml-api:2.2-111.vc6598e30cc65
ssh-credentials:305.v8f4381501156
ssh-slaves:2.877.v365f5eb_a_b_eec
sshd:3.312.v1c601b_c83b_0e
started-by-envvar:1.0
structs:325.vcb_307d2a_2782
subversion:2.17.3
telegram-notifications:1.4.0
throttle-concurrents:2.14
timestamper:1.25
token-macro:359.vb_cde11682e0c
trilead-api:2.84.v72119de229b_7
variant:60.v7290fc0eb_b_cd
view-job-filters:2.3
windows-slaves:1.8.1
workflow-aggregator:596.v8c21c963d92d
workflow-api:1283.v99c10937efcb_
workflow-basic-steps:1042.ve7b_140c4a_e0c
workflow-cps:3673.v5b_dd74276262
workflow-cps-global-lib:609.vd95673f149b_b
workflow-durable-task-step:1289.v4d3e7b_01546b_
workflow-job:1326.ve643e00e9220
workflow-multibranch:746.v05814d19c001
workflow-scm-step:408.v7d5b_135a_b_d49
workflow-step-api:639.v6eca_cd8c04a_a_
workflow-support:839.v35e2736cfd5c
ws-cleanup:0.45

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

Ubuntu 22.04

Reproduction steps

  1. Instantiate a JenkinsServer (default config, just URL, username and api token)
  2. Obtain a JobWithDetails by name
  3. Starting a build with parameters (job.build(parameters) ) three time in a row, with the same parameters

Expected Results

Three different builds, or a single build, but no errors

Actual Results

A HttpResponseException in the HttpResponseValidator, caused by a 404 Not Found, caused by following the Location header of the second or third consecutive build call.

Anything else?

The first call returns always a 200-something code, the second or the third returns a 303 with a queue item url in the Location header. The backing HTTP client follows the Location url, that is invalid because it has no /api/json suffix.

After disabling the redirect handling in the HTTP client, the result is a single build, without any exception. The QueueReferenceinstances returned by the three calls to .build have the same queueItem value.

This is my workaround. I think that this should be the default configuration for the HttpClient, as the Location header in the 303 response is not a valid redirect location.

        this.jenkinsServer = new JenkinsServer(
                new JenkinsHttpClient(
                        new URI(jenkinsProperties.getUrl()),
                        HttpClientBuilder.create().disableRedirectHandling(),
                        jenkinsProperties.getUsername(),
                        jenkinsProperties.getPassword()
                )
        );

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions