Is it possible to execute Jenkins jobs from Powershell or Bash or Groovy scripts? -
i have separated quite small jenkins jobs.
now need configure job depending on selected user parameters (selected through checkboxes?) execute of them.
i start them powershell or bash or groovy script. possible?
if using groovy in postbuild/pipeline step, can start job via jenkins api.
for example, parameterless builds:
import hudson.model.* jenkins.instance.getitem("my job").schedulebuild(5)
and parameterized builds:
import hudson.model.* jenkins.instance.getitem("my job").schedulebuild( 5, new cause.upstreamcause( currentbuild ), new parametersaction([ new stringparametervalue( "my parameter name", "my parameter value" ) ]));
you can use jenkins rest api rest. example, hitting following url:
parameterless:
curl -x post jenkins_url/job/job_name/build
parameterized:
curl -x post jenkins_url/job/job_name/buildwithparameters?myparametername=myparametervalue
Comments
Post a Comment