I'm creating a Jenkins job which gets triggered by a commit to Gerrit.
pipelineJob(jobName) {
displayName(displayString)
triggers {
gerrit {
events {
patchsetCreated()
}
project('plain:Verify', ['ant:**'])
configure { project ->
project / triggers << 'com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject' {
serverName('aj-Gerrit')
}
}
}
}
}
This works fine and when I look in the UI, I see this.
However, what I would like is for the Gerrit server aj-Gerrit to be selected by default and not Any Server
I've tried to achieve this by adding in the configure block in my Groovy code,
configure { project ->
project / triggers << 'com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject' {
serverName('aj-Gerrit')
}
}
but it doesn't seem to be working.
Is there a way to select a server by default?


The
configurefunction doesn't exist in thegerritclosure. Usually, all available Job DSL options are visible on the page:However, the Gerrit plugin breaks the page (cause: JENKINS-53250).
This is generated XML when a server is added manually to the job:
You could try to use (different class than the one you used):
If it doesn't work, then more elements from the generated XML must be provisioned too.