Plugin Information |
---|
View Slave Prerequisites on the plugin site for more information. |
This plugin allows to check prerequisites on slave before a job can run a build on it
Goal
Labels can be used to group slave nodes based on various criteria, but in some cases such criteria may be dynamic : free disk space, available license token, attached hardware. This plugin let a job define a script to be executed on candidate nodes as the Queue is searching for the best available executor to check if some dynamic prerequisites are met, and to veto a node if not.
Usage
Job can define a shell script to be ran as the Build Queue is looking for the best node to host the build.
This script will be executed asynchronously by the build queue, and the job will stay in waiting state until one of the nodes successfully run the script. On failure, a new attempt on the node will run as the next Build Queue maintenance cycle occurs, so that the script can be used to check for dynamic resources to be available just before the job starts on the node.
Please note this plugin requires Jenkins 1.452 and later, as it depends on 1ac4872ecdc500c63c0dbfce5e4beb5ce78369e5
Changelog
Version 1.1 (not released yet)
Version 1.0 (released february 29, 2012)
- initial release
6 Comments
Unknown User (cnspring2002@yahoo.com.cn)
I need to use this plugin as follows:
project1 project2
| |
__________
|
project3
For project1, it will trigger project3 with parameter trigger plugin with the parameter para="p1"
For project2, it will trigger project3 with parameter trigger plugin with the parameter para="p2"
And I need project3 to run as follows:
a) when receive para="p1", it will launch this project on slave1;
b) when receive para="p2", it will launch this project on slave2;
So, my question is: it seems this plugin in cannot handle env variable from upstream project (just like project1 & project2).
I look through the code, and find:
public class JobPrerequisites extends JobProperty<AbstractProject<?, ?>> implements Action {
public CauseOfBlockage check(Node node) throws IOException, InterruptedException
}
Here, it seems we can have no chance to get environment variable. Of course, in JobProperty, we can add one override method:
public boolean prebuild(AbstractBuild<?,?> build, BuildListener listener) {
try
catch (IOException e)
catch (InterruptedException e)
return true;
}
public boolean prebuild(AbstractBuild<?,?> build, BuildListener listener)
And this method has the parameter build, so we can get the environment variable. However, I give a try, it seems the run sequence of this method is behind the "check". So for method "check", we still cannot get environment variable.
How can I make my design work? Any good suggestion to modify "Slave Prerequisites Plugin" or good practice which I can use other plugin to achieve my goal?
My mail is fl.shen@yahoo.com.cn, please feel ease to mail me if you have good suggestion, thanks very much.
Unknown User (alex01ves)
I'd like to have the option to take the node offline if the prerequisites fail.
Unknown User (skdzzz)
I also think that being able to take the node offline would be very usefull.
Unknown User (alex01ves)
I've played around with this plugin for a little while.
As it turns out, the shell script that is being executed before the build does not see any environment variables that are visible from inside Jenkins. I cannot access NODE_NAME, JENKINS_URL, or any other variables that I set inside Jenkins. It would be really nice to have this functionality, because I want to use this plugin to perform environment checks.
Filed as https://issues.jenkins-ci.org/browse/JENKINS-15028
Unknown User (skdzzz)
Is it possible to check the output of the script execution anywhere?
Unknown User (ccliangbo)
if you want to get the build parameters in your shell script, clone my change and compile it yourself before my change is merged.
https://github.com/ccliangbo/slave-prerequisites-plugin/commit/330391dc2c0e513327a470b21656e33ea58fe205