Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-51874

Parameterized Remote Trigger does not use URL for Build Token Root Plugin

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Labels:
      None
    • Environment:
      Jenkins ver 2.126 (local) and 2.118 (remote)
      Parameterized Remote Trigger Plugin ver 3.0.0
      Build Token Root Plugin ver 1.4
    • Similar Issues:

      Description

      I have configured a Remote Host as shown in the following screenshot. Notably, I have checked the box to use the 'build token root' support. I expect no authentication is necessary for this, per the description of the Build Token Root Plugin.

      However, when I try to run a remote job from a pipeline using this:

      triggerRemoteJob job: 'fake-qg1', parameters: 'someParam=hi world', remoteJenkinsName: 'Remote Test Jenkins', token: 'sometokenyoullneverguess'
      

      It does not use the build token root endpoint, and therefore it fails due to authentication issues.

      [Pipeline] triggerRemoteJob
      ################################################################################################################
        Parameterized Remote Trigger Configuration:
          - job:                     fake-qg1 
          - remoteJenkinsName:       Remote Test Jenkins
          - auth:                    'No Authentication'
          - parameters:              [someParam=hi world]
          - blockBuildUntilComplete: true
          - connectionRetryLimit:    5
      ################################################################################################################
      ERROR: Remote build failed with 'ForbiddenException' for the following reason: 'Server returned 403 - Forbidden. User does not have enough permissions for this request: http://***redacted***/jenkins/job/fake-qg1/api/json'.
      

      If I use an API Token, then it, of course works. But I want to use the 'Build Token Root Plugin' method of triggering the job. The correct URL (I believe something like /jenkins/buildByToken/buildWithParameters? job=NAME&token=SECRET) needs to be used instead of the regular job API which requires an authenticated user.

      I have confirmed that the build token root URL is available on the remote Jenkins, but it appears the Parameterized Remote Trigger Plugin is not even trying to use it, despite having checked the "Enable 'build token root' support" checkbox in the Remote Host configuration.

        Attachments

          Issue Links

            Activity

            Hide
            dshvedchenko Denis Shvedchenko added a comment -

            Hello, from stack trace it is obvious that root cause lays in 

            https://github.com/jenkinsci/parameterized-remote-trigger-plugin/blob/master/src/main/java/org/jenkinsci/plugins/ParameterizedRemoteTrigger/RemoteBuildConfiguration.java#L624

            Executing side tries to understand whenever remote job supports parameters or not before constructing url that optionally uses Build Root Token, that performed in HttpHelper.buildTriggerUrl(...)

            May 23, 2019 1:02:09 PM org.jenkinsci.plugins.ParameterizedRemoteTrigger.utils.HttpHelper sendHTTPCall
            WARNING: Server returned 403 - Forbidden. User does not have enough permissions for this request: https://*****************************/job
            /reference/job/provider/api/json?tree=actions[parameterDefinitions],property[parameterDefinitions],name,fullName,displayName,fullDisplayName,url - [HTTP/
            1.1 403 Forbidden]
            org.jenkinsci.plugins.ParameterizedRemoteTrigger.exceptions.ForbiddenException: Server returned 403 - Forbidden. User does not have enough permissions fo
            r this request: https://************************************/job/reference/job/provider/api/json?tree=actions[parameterDefinitions],property[param
            eterDefinitions],name,fullName,displayName,fullDisplayName,url
                    at org.jenkinsci.plugins.ParameterizedRemoteTrigger.utils.HttpHelper.sendHTTPCall(HttpHelper.java:474)
                    at org.jenkinsci.plugins.ParameterizedRemoteTrigger.utils.HttpHelper.tryCall(HttpHelper.java:571)
                    at org.jenkinsci.plugins.ParameterizedRemoteTrigger.utils.HttpHelper.tryGet(HttpHelper.java:591)
                    at org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration.doGet(RemoteBuildConfiguration.java:877)
                    at org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration.getRemoteJobMetadata(RemoteBuildConfiguration.java:1049)
                    at org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration.performTriggerAndGetQueueId(RemoteBuildConfiguration.java:624) <-----
                    at org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration.perform(RemoteBuildConfiguration.java:591)
                    at org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration.perform(RemoteBuildConfiguration.java:557)
                    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
                    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
                    at hudson.model.Build$BuildExecution.build(Build.java:206)
                    at hudson.model.Build$BuildExecution.doRun(Build.java:163)
                    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
                    at hudson.model.Run.execute(Run.java:1816)
                    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
                    at hudson.model.ResourceController.execute(ResourceController.java:97)
                    at hudson.model.Executor.run(Executor.java:429)
             
            Show
            dshvedchenko Denis Shvedchenko added a comment - Hello, from stack trace it is obvious that root cause lays in  https://github.com/jenkinsci/parameterized-remote-trigger-plugin/blob/master/src/main/java/org/jenkinsci/plugins/ParameterizedRemoteTrigger/RemoteBuildConfiguration.java#L624 Executing side tries to understand whenever remote job supports parameters or not before constructing url that optionally uses Build Root Token, that performed in HttpHelper.buildTriggerUrl(...) May 23, 2019 1:02:09 PM org.jenkinsci.plugins.ParameterizedRemoteTrigger.utils.HttpHelper sendHTTPCall WARNING: Server returned 403 - Forbidden. User does not have enough permissions for this request: https: / /*****************************/ job /reference/job/provider/api/json?tree=actions[parameterDefinitions],property[parameterDefinitions],name,fullName,displayName,fullDisplayName,url - [HTTP/ 1.1 403 Forbidden] org.jenkinsci.plugins.ParameterizedRemoteTrigger.exceptions.ForbiddenException: Server returned 403 - Forbidden. User does not have enough permissions fo r this request: https: / /************************************/ job/reference/job/provider/api/json?tree=actions[parameterDefinitions],property[param eterDefinitions],name,fullName,displayName,fullDisplayName,url at org.jenkinsci.plugins.ParameterizedRemoteTrigger.utils.HttpHelper.sendHTTPCall(HttpHelper.java:474) at org.jenkinsci.plugins.ParameterizedRemoteTrigger.utils.HttpHelper.tryCall(HttpHelper.java:571) at org.jenkinsci.plugins.ParameterizedRemoteTrigger.utils.HttpHelper.tryGet(HttpHelper.java:591) at org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration.doGet(RemoteBuildConfiguration.java:877) at org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration.getRemoteJobMetadata(RemoteBuildConfiguration.java:1049) at org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration.performTriggerAndGetQueueId(RemoteBuildConfiguration.java:624) <----- at org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration.perform(RemoteBuildConfiguration.java:591) at org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration.perform(RemoteBuildConfiguration.java:557) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744) at hudson.model.Build$BuildExecution.build(Build.java:206) at hudson.model.Build$BuildExecution.doRun(Build.java:163) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504) at hudson.model.Run.execute(Run.java:1816) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429)
            Hide
            bzwoin Boudewijn van Klingeren added a comment -

            I found out that you need to allow anonymous access in the global security settings of the Jenkins instance. This way, the Parameterized Remote Trigger Plugin is able to fetch the remote job metadata to decide if it should execute a normal build or a build with parameters.

            However, it would be nice to have the plugin decide if it should execute a normal build or a build with parameters without fetching metadata when the build token root plugin is active, maybe based on the presence of parameters?

            Show
            bzwoin Boudewijn van Klingeren added a comment - I found out that you need to allow anonymous access in the global security settings of the Jenkins instance. This way, the Parameterized Remote Trigger Plugin is able to fetch the remote job metadata to decide if it should execute a normal build or a build with parameters. However, it would be nice to have the plugin decide if it should execute a normal build or a build with parameters without fetching metadata when the build token root plugin is active, maybe based on the presence of parameters?

              People

              Assignee:
              cashlalala KaiHsiang Chang
              Reporter:
              tommyludwig Tommy Ludwig
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated: