[ Jenkins ] 3 ways to trigger jenkins task on the remote host

NOTE : task token can be get from `Build Triggers` > `Trigger builds remotely (e.g., from scripts)`

way1) install Parameterized Remote Trigger Plugin

We can login using Username + Token

way2) use curl

 $ curl -kX POST https://jenkins_url/job/jenkin_job_name/build \
--data token=whatever_token_it_is \
--data-urlencode json="{\"parameter\": [{\"name\":\"param1\", \"value\":\"value1\"}]}" 

con : do not know whether the task is finished running, hence the task result ( success/fail ) is unknown

NOTE : This `Build Trigger > Trigger builds remotely (e.g., from scripts)`option will be available if we enable security on

Manage Jenkins > Configure Global Security > Enable security

way3)  use jenkins-cli.jar

NOTE : the public key need to be setup on https://jenkins_url/me/configure

( ref : Michaël’s suggestion on http://jenkins-ci.361315.n4.nabble.com/jenkins-command-line-Failed-to-authenticate-with-your-SSH-keys-td4642440.html )

 $ java -jar /path/to/jenkins-cli.jar -noCertificateCheck -s https://jenkins_url/ -i /whatever/path/to/priv_key_id_rsa build jenkin_job_name -p param1=value1 -p param2=value2 -s -v

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s