These are chat archives for jenkinsci/jenkins

Mar 2018
Mar 26 2018 10:47
Hi all! I'm fairly new to jenkins and i have a small question:
Is it possible from jenkins REST API to receive the details of the last build of a job that ran with a certain parameter value?
(last build of JOB_NAME filtered by PARAM_X = MY_VALUE)
Nikita Kunets
Mar 26 2018 11:57

Hi everyone. I'm trying to configure ssh-plugin via groovy script and have question about StaplerRequest interface: how can I easily get an object with this interface? At the moment I have something like this

def descriptor = Jenkins.instance.getDescriptor("org.jvnet.hudson.plugins.SSHBuildWrapper")
def test = [hostname:'test',port:'22', credentialId:'test', pty:false, timeout:'60', serverAliveInterval:'123']
JSONObject json = new JSONObject()
json.put("sites", test as JSONObject)
StaplerRequest req = //get Stapler Request object
descriptor.configure(req, json)

I'd appreciate any help

Alex Earl
Mar 26 2018 15:58
@dkder3k I've never had good success in creating my own StaplerRequest, are there no accessible getters/setters for what you need?
Also, from looking at the configure method, you may not need StaplerRequest at all (pass null)
oh, nm, it is used
Nikita Kunets
Mar 26 2018 17:31
@slide unfortunately there are no accessible getters/setters in my situation. In Jenkins script console there is getCurrentRequest() method to get StaplerRequest for current page but it is unavailable for script outside (f.e. for script in jenkins/init.groovy.d directory).
Alex Earl
Mar 26 2018 20:11
You could try reflection
or a PR for the ssh-plugin :)
Nikita Kunets
Mar 26 2018 21:40
@slide I have no such great experience at reflection api and jenkins plugin development but I will try.
Thank you :smile:
Alex Earl
Mar 26 2018 21:54
The PR should be simple, just add a setSites method to the descriptor