Display authenticating user when building with remote-trigger via curl on Jenkins

Hey Folks,

Requirement: Need to print the account name or ID, authenticating the remote-triggered on the build on Jenkins.

Resources: Jenkins version:

  1. instance 1 : 2.176.2

  2. Instance 2 : 2.504.2

scenario:

we are using multiple Jenkins servers to serve various purpose respectively.

Remote-triggered builds are running successfully.

When build triggered using remote curl call it show given below line on console logs : “Started by remote host 192.29.0.10”

As oppose to this any normal build (from Jenkins web-interface), message on build logs shows “Started by user Foo”.

We are using given below curl call to trigger the remote build.

curl -X POST  http://foo:secret_token@192.168.24.126:8080/job/my_testjob/buildWithParameters?token=secret

(Note: same curl call works without issues on both the versions of Jenkins (2.176.2 & 2.504.2) )

  • what I am trying to achieve?

When remote triggered builds are made via curl, console log should also print the UserID who was associated with authenticating remote-trigger. ( in case of above curl it would be user “foo” )

Have already tried multiple solution as suggested by AI and as per Jenkins Remote Trigger User Name - Stack Overflow

Regards
(Please find below Jenkins version and other details.)

Jenkins Setup:

  1. instance 1 : 2.176.2
Jenkins: 2.176.2
OS: Linux - 3.10.0-514.26.1.el7.x86_64
Java: 1.8.0_212 - Oracle Corporation (OpenJDK 64-Bit Server VM)
---
ace-editor:1.1
analysis-core:1.96
analysis-model-api:5.3.0
ansible:1.0
ant:1.9
antisamy-markup-formatter:1.5
apache-httpcomponents-client-4-api:4.5.5-3.0
backup:1.6.1
bouncycastle-api:2.17
branch-api:2.5.4
build-name-setter:2.0.1
build-pipeline-plugin:1.5.8
buildresult-trigger:0.17
changes-since-last-success:0.6
checkstyle:4.0.0
cloudbees-folder:6.9
command-launcher:1.3
conditional-buildstep:1.3.6
create-fingerprint:1.2
credentials:2.2.1
cvs:2.14
display-url-api:2.3.2
email-ext:2.66
emailext-template:1.1
extended-choice-parameter:0.78
external-monitor-job:1.7
git:3.12.0
git-client:2.8.0
github-api:1.95
github-oauth:0.24
htmlpublisher:1.18
jackson2-api:2.9.9.1
javadoc:1.5
jdk-tool:1.3
jquery:1.12.4-0
jquery-detached:1.2.1
jquery-ui:1.0.2
jsch:0.1.55.1
jslint:0.8.2
junit:1.28
ldap:1.20
mailer:1.24
mapdb-api:1.0.9.0
matrix-auth:2.4.2
matrix-combinations-parameter:1.3.0
matrix-project:1.14
mattermost:2.7.0
maven-plugin:3.4
metrics:4.0.2.6
monitoring:1.79.0
nodelabelparameter:1.7.2
pam-auth:1.5.1
parameterized-trigger:2.35.2
performance:3.17
plain-credentials:1.5
publish-over:0.22
publish-over-ssh:1.20.1
purge-job-history:1.1
role-strategy:2.13
run-condition:1.2
schedule-build:0.5.1
scm-api:2.6.3
script-security:1.62
ssh:2.6.1
ssh-credentials:1.17.1
ssh-slaves:1.30.1
structs:1.20
subversion:2.12.2
summary_report:1.15
testng-plugin:1.15
token-macro:2.8
translation:1.16
variant:1.3
view-job-filters:2.1.1
warnings:5.0.1
warnings-ng:5.3.0
windows-slaves:1.4
workflow-api:2.36
workflow-cps:2.73
workflow-job:2.33
workflow-scm-step:2.9
workflow-step-api:2.20
workflow-support:3.3
xvfb:1.1.3

===================================================================

  1. Instance 2 : 2.504.2
Jenkins: 2.504.2
OS: Linux - 3.10.0-1160.el7.x86_64
Java: 21.0.7 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)
---
Parameterized-Remote-Trigger:3.2.2
ant:518.v8d8dc7945eca_
antisamy-markup-formatter:173.v680e3a_b_69ff3
apache-httpcomponents-client-4-api:4.5.14-269.vfa_2321039a_83
apache-httpcomponents-client-5-api:5.5-166.v870a_96374f91
asm-api:9.8-163.vb_2a_96d3f9c3c
authentication-tokens:1.144.v5ff4a_5ec5c33
blueocean:1.27.21
blueocean-bitbucket-pipeline:1.27.21
blueocean-commons:1.27.21
blueocean-config:1.27.21
blueocean-core-js:1.27.21
blueocean-dashboard:1.27.21
blueocean-display-url:2.4.4
blueocean-events:1.27.21
blueocean-git-pipeline:1.27.21
blueocean-github-pipeline:1.27.21
blueocean-i18n:1.27.21
blueocean-jwt:1.27.21
blueocean-personalization:1.27.21
blueocean-pipeline-api-impl:1.27.21
blueocean-pipeline-editor:1.27.21
blueocean-pipeline-scm-api:1.27.21
blueocean-rest:1.27.21
blueocean-rest-impl:1.27.21
blueocean-web:1.27.21
bootstrap5-api:5.3.7-860.v1251c115c90c
bouncycastle-api:2.30.1.81-264.v95c79c0e772c
branch-api:2.1244.vf95c81f1641c
build-timeout:1.38
caffeine-api:3.2.2-178.v353b_8428ed56
checks-api:373.vfe7645102093
cloudbees-bitbucket-branch-source:936.4.4
cloudbees-folder:6.1037.v4cb_8573b_72a_a_
commons-lang3-api:3.18.0-98.v3a_674c06072d
commons-text-api:1.14.0-194.v804a_dc3a_1b_d8
credentials:1419.v2337d1ceceef
credentials-binding:702.vfe613e537e88
dark-theme:524.vd675b_22b_30cb_
display-url-api:2.217.va_6b_de84cc74b_
durable-task:595.ve87b_f1318d67
echarts-api:6.0.0-1146.v5c8f3b_8f0573
eddsa-api:0.3.0.1-19.vc432d923e5ee
email-ext:1925.v1598902b_58dd
favorite:2.237.v79163ca_8b_892
font-awesome-api:7.0.0-851.vd1feb_218a_a_63
git:5.7.0
git-client:6.3.3
github:1.44.0
github-api:1.330-492.v3941a_032db_2a_
github-branch-source:1848.v42f74f7f4500
gradle:2.16.1149.v711b_998b_0532
gson-api:2.13.1-153.vb_3d0c48a_a_b_4a_
handy-uri-templates-2-api:2.1.8-36.v85e4cb_234a_13
htmlpublisher:427
instance-identity:203.v15e81a_1b_7a_38
ionicons-api:94.vcc3065403257
jackson2-api:2.19.2-408.v18248a_324cfe
jakarta-activation-api:2.1.3-2
jakarta-mail-api:2.1.3-3
javax-activation-api:1.2.0-8
jaxb:2.3.9-133.vb_ec76a_73f706
jenkins-design-language:1.27.21
jjwt-api:0.11.5-120.v0268cf544b_89
joda-time-api:2.14.0-149.v1c3ce991d1b_9
jquery3-api:3.7.1-594.vb_3864f326cf0
json-api:20250517-173.v596efb_962a_31
json-path-api:2.9.0-190.veefca_05d5477
jsoup:1.21.2-66.v6ea_38164b_8a_2
junit:1354.v5b_348580de7f
ldap:780.vcb_33c9a_e4332
mailer:522.va_995fa_cfb_8b_d
matrix-auth:3.2.8
matrix-project:856.v4c352b_3a_b_23e
metrics:4.2.33-484.v2fcd689980d1
mina-sshd-api-common:2.16.0-167.va_269f38cc024
mina-sshd-api-core:2.16.0-167.va_269f38cc024
okhttp-api:4.11.0-189.v976fa_d3379d6
pam-auth:1.12
parameterized-trigger:873.v8b_e37dd8418f
pipeline-build-step:571.v08a_fffd4b_0ce
pipeline-github-lib:65.v203688e7727e
pipeline-graph-analysis:241.vc3d48fb_b_2582
pipeline-graph-view:628.va_6f6a_1d12848
pipeline-groovy-lib:752.vdddedf804e72
pipeline-input-step:534.v352f0a_e98918
pipeline-milestone-step:138.v78ca_76831a_43
pipeline-model-api:2.2265.v140e610fe9d5
pipeline-model-definition:2.2265.v140e610fe9d5
pipeline-model-extensions:2.2265.v140e610fe9d5
pipeline-stage-step:322.vecffa_99f371c
pipeline-stage-tags-metadata:2.2265.v140e610fe9d5
plain-credentials:199.v9f8e1f741799
plugin-util-api:6.1167.v022176c7e0ca_
pubsub-light:1.19
resource-disposer:0.25
scm-api:707.v749f968369d4
script-security:1378.vf25626395f49
slack:795.v4b_9705b_e6d47
snakeyaml-api:2.3-125.v4d77857a_b_402
sse-gateway:1.28
ssh-agent:386.v36cc0c7582f0
ssh-credentials:361.vb_f6760818e8c
ssh-slaves:3.1071.v0d059c7b_c555
structs:353.v261ea_40a_80fb_
theme-manager:319.v9193461f9671
thinBackup:2.1.3
timestamper:1.30
token-macro:477.vd4f0dc3cb_cf1
trilead-api:2.209.v0e69b_c43c245
variant:70.va_d9f17f859e0
workflow-aggregator:608.v67378e9d3db_1
workflow-api:1384.vdc05a_48f535f
workflow-basic-steps:1079.vce64b_a_929c5a_
workflow-cps:4183.v94b_6fd39da_c1
workflow-durable-task-step:1452.v0ee719c104a_7
workflow-job:1540.v295eccc9778f
workflow-multibranch:811.vcd33d074c2a_0
workflow-scm-step:437.v05a_f66b_e5ef8
workflow-step-api:706.v518c5dcb_24c0
workflow-support:976.vb_d9493c2eb_09
ws-cleanup:0.49

That is because you trigger the job with the job specific token. buildWithParameters?token=secret
Make sure that the user foo has the permission to build the job and then omit the token, e.g. buildWithParameters?myparam=value1 without specifying the token. Then you will get the correct user cause

This is working, I had to “Enable project-based security” on the job and provide the necessary access to build and read for given user. ( As suggested by @mawinter69 )

Thank you for your time and suggestions

Regards

I have another doubt over here, That is as given below.

Earlier I was trying to make a build using both user tokens and job specific tokens, in such cases console logs use to reflect, from which host the build was triggered.

Now that I’ve enabled “Enable project-based security” inside job, console logs are showing which user has triggered the build.

Both the cases are working fine independently, and reflecting the details as per mentioned respectively.

What new thing I am trying to achieve next over here is that console logs should reflect both host from where build was triggered and user who was responsible for triggering this build.