> > we use Go but you can use curl or any HTTP client, it is something like > this > > JENKINS_CRUMB=$(curl --silent > "$JENKINS_URL/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,\":\",//crumb)") > curl --silent -X POST -H "${JENKINS_CRUMB}" -F "script=<script.groovy" > ${JENKINS_URL}/scriptText > >
Interesting, thanks! We use jenkins-cli, more or less like this: cat script.groovy | java -jar ./jenkins-cli.jar -ssh -user userID -i key_rsa -s "${server}" groovy = >> output.xml Probably based on an old approach. I'll switch it with curl... yep, this data should be in the API, probably it is a matter of adding an > annotation in the Class > > Indeed, the data is there, it seems that an *@Exported* annotation would do it: https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Queue.java#L2155 I'm not sure about the implications though. Anyway, I would like to get the Label because I need to know in advance whether I should connect a node to that Master or not. But I forgot the fact that the Label can be a regular expression, and that kind of kills my purpose because I would then need to resolve the expression also in advance. And replicating the Jenkins mechanism for that wouldn't be so wise in the long term. I tried to use the method *Jenkins.instance.queue.countBuildableItemsFor(Label)* to ask Jenkins itself to check that for me, but that didn't work for me as I expected... For example, I triggered a build that requests the expression "myLabelA || myLabelB". Then I programmatically created a Label that would match that. Yet, Jenkins couldn't match it for some reason: import hudson.model.labels.* Jenkins.instance.queue.items.each { println ">> Label expression from the pending build:" def labelFromQueueJob = it.getAssignedLabel() println "Type: " + labelFromQueueJob.class println "Expression: " + labelFromQueueJob println ">> countBuildableItemsFor " + labelFromQueueJob + " : " + Jenkins .instance.queue.countBuildableItemsFor(labelFromQueueJob) } println "\n>> Artificially created Label expression:" LabelExpression artificialLabelExp = new LabelExpression.Or(new LabelAtom( "myLabelA"),new LabelAtom("myLabelB")) println "Type: " + artificialLabelExp.class println "Expression: " + artificialLabelExp println ">> countBuildableItemsFor " + artificialLabelExp + " : " + Jenkins. instance.queue.countBuildableItemsFor(artificialLabelExp) Output: >> Label expression from the pending build: Type: class hudson.model.labels.LabelExpression$Or Expression: myLabelA||myLabelB >> countBuildableItemsFor myLabelA||myLabelB : 1 >> Artificially created Label expression: Type: class hudson.model.labels.LabelExpression$Or Expression: myLabelA||myLabelB >> countBuildableItemsFor myLabelA||myLabelB : 0 No questions left. I'm glad that you pointed out that curl solution. I've certainly overlook it! -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/64dc6461-704b-41a0-a7db-53d61657b444%40googlegroups.com.