My suggestions were for triggering other jobs on the Jenkins server that
run on different machines.
i.e
Project A
starts either
Project 1 - tied to windows nodes
or
Project 2 - tied to linux nodes
Where the script in Projects 1 & 2 actually controls the tests, running on
the node.
e.g. Copies files to test across and then calls a batch script, or shell
commands.
This means that you label all of the nodes that these projects can run on
with the approiate labels,
Note:you can have multiple labels on slaves and projects and multiple
slaves with the same labels
so you might label the nodes as:
Slave 1 - windows testlink
Slave 2 - linux testlink
Slave 3 - windows build
Slave 4 - linux build
Slave 5 - windows testlink
and the project 1 with windows testlink which would cause it to run on
slave 1 or 5.
and the project 2 with linux testlink which would cause it to run on slave 2
RE: groovy
This is basically the same as java with some additions so most valid java
will work.
Here is an example of what you are trying to acheive using the Enviroment
variable ABC,
starting either windows_test or linux_test projects or failing the build if
it is something else.
import hudson.model.Cause;
def envars = manager.build.getEnvironment(manager.listener);
if (envars.get("ABC") == "WINDOWS"){
// windows bit
def foo = manager.hudson.getJob( 'windows_test' )
foo.scheduleBuild( 2, new Cause.UpstreamCause( manager.build ))
}
else if (envars.get("ABC") == "LINUX") {
// linux bit
def foo = manager.hudson.getJob( 'linux_test' )
foo.scheduleBuild( 2, new Cause.UpstreamCause( manager.build ))
} else {
//all others
manager.createSummary("warning.gif").appendText("<h1>Not a valid
platform</h1>", false, false, false, "red")
manager.buildFailure()
}
And if you want to pass parameters to the downstream builds.
use the following
import hudson.model.ParametersAction;
def params = []
params.push( new StringParameterValue( 'MINOR', 2 ) )
def foo = manager.hudson.getJob( 'Foo' )
foo.scheduleBuild( 2, new Cause.UpstreamCause( manager.build ), new
ParametersAction( params ) )
Hope this helps.
Chris
On Thursday, September 6, 2012 3:18:36 AM UTC+1, bandy wrote:
>
> Hi Chris,
>
> Thanks for the reply. I reviewed all options that you have mentioned. I am
> trying to write a system groovy script for my use case. But there seems not
> many resources available in the internet for groovy. I am stuck in place
> where I want to trigger downstream job (in Windows or in Linux) depending
> on environment variable from TestLink (which I am able to work with). I
> dont have any idea so far how can i trigger build in remote machines using
> groovy script.
>
> Any ideas on that or any other resource that you know might help??
>
> Rgrds
> bandy
>
>
>
> On Monday, September 3, 2012 7:23:10 PM UTC+8, cjo wrote:
>>
>> To run one or other of the downstream jobs, it currently not a simple
>> case as, but there are are several different ways of doing it.
>>
>> Use a groovy post build script to trigger one of the builds
>>
>> You could use the Parametrized trigger [1] in combination with the
>> conditional build step plugin,[2] to run the jobs as build steps within a
>> job.
>>
>> This would mean having a conditional buildstep for each of the platforms,
>> where the environment variable is checked
>> which contains the trigger build on other projects for the correct
>> project.
>>
>>
>> If you want to use the conditional part with the Parametrized trigger as
>> a trigger for the downstream properly there is a pull request for that on
>> github,
>> that you can build and test. [3]
>>
>> Chris
>>
>> [1]
>> https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin
>> [2]
>> https://wiki.jenkins-ci.org/display/JENKINS/Conditional+BuildStep+Plugin
>> [3] https://github.com/jenkinsci/parameterized-trigger-plugin/pull/17
>>
>> On Monday, September 3, 2012 10:54:45 AM UTC+1, bandy wrote:
>>>
>>> Hi,
>>>
>>> I am new in Jenkins and wandering for few days to get my head around the
>>> topic "How to trigger downstream job based on certain conditions ?"
>>>
>>> Details:
>>>
>>> I have testlink integrated with jenkins which manages the test suite and
>>> test cases. I have a custom field "Test Client Platform Type" in TestLink.
>>> The tester can specify in the TestLink if the test case has to be run in
>>> Windows or Linux Platform.
>>> I fetch the custom field in jenkins successfully but can't figure out
>>> how to trigger downstream jobs in linux and windows client depending on the
>>> environment variable.
>>>
>>> Any ideas ??
>>>
>>>
>>>