How to enable "Trigger builds remotely (e.g., from scripts)" in scripted pipeline job?


I am getting the below error when trying to use the pipelineTriggers property “$class: ‘RemoteBuildTrigger’” in the scripted pipeline job in the following code.

I am using [Jenkins 2.346.2].

Can someone please help me to resolve this error?

timestamps {
  node() {
            [$class: 'RemoteBuildTrigger', remoteBuildToken: 'XXXXX']      
      [$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: true], 
          defaultValue: '',
          description: '',
          name: 'Repo URL'
    stage('Prepare') { 
      echo "Prepare stage"
java.lang.UnsupportedOperationException: no known implementation of class hudson.triggers.Trigger is named RemoteBuildTrigger
	at org.jenkinsci.plugins.structs.describable.DescribableModel.resolveClass(
	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(
	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerceList(
	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(
	at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(
	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(
Caused: java.lang.IllegalArgumentException: Could not instantiate {triggers=[{$class=RemoteBuildTrigger, remoteBuildToken=XXXXX}]} for

It’s not possible to configure this I think. If you configure it manually you will get this xml


So you can see that this is not modelled as a trigger, hence you can’t configure it via triggers.

The approach to allow triggering of jobs this way is anyway not recommended.
Read the help that you get for this option for alternatives.