Adding builder for SSH plugin

This builder allows running builder on remote machine using SSH Plugin
https://wiki.jenkins-ci.org/display/JENKINS/SSH+plugin

Change-Id: I8ea72e75bca1f9b5b087303d73b172fed192f95d
This commit is contained in:
Ilia Meerovich 2015-04-28 14:47:49 +03:00
parent 29a09458d2
commit 2b5f9344b7
4 changed files with 37 additions and 0 deletions

View File

@ -1870,6 +1870,29 @@ def github_notifier(parser, xml_parent, data):
'com.cloudbees.jenkins.GitHubSetCommitStatusBuilder')
def ssh_builder(parser, xml_parent, data):
"""yaml: ssh-builder
Executes command on remote host
Requires the Jenkins `SSH plugin.
<https://wiki.jenkins-ci.org/display/JENKINS/SSH+plugin>`_
:arg str ssh-user-ip: user@ip:ssh_port of machine that was defined
in jenkins according to SSH plugin instructions
:arg str command: command to run on remote server
Example:
.. literalinclude:: /../../tests/builders/fixtures/ssh-builder.yaml
"""
builder = XML.SubElement(
xml_parent, 'org.jvnet.hudson.plugins.SSHBuilder')
try:
XML.SubElement(builder, 'siteName').text = str(data['ssh-user-ip'])
XML.SubElement(builder, 'command').text = str(data['command'])
except KeyError as e:
raise MissingAttributeError("'%s'" % e.args[0])
def sonar(parser, xml_parent, data):
"""yaml: sonar
Invoke standalone Sonar analysis.

View File

@ -73,6 +73,7 @@ jenkins_jobs.builders =
shining-panda=jenkins_jobs.modules.builders:shining_panda
sonar=jenkins_jobs.modules.builders:sonar
sonatype-clm=jenkins_jobs.modules.builders:sonatype_clm
ssh-builder=jenkins_jobs.modules.builders:ssh_builder
system-groovy=jenkins_jobs.modules.builders:system_groovy
trigger-builds=jenkins_jobs.modules.builders:trigger_builds
jenkins_jobs.reporters =

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<builders>
<org.jvnet.hudson.plugins.SSHBuilder>
<siteName>foo@bar:22</siteName>
<command>echo foo</command>
</org.jvnet.hudson.plugins.SSHBuilder>
</builders>
</project>

View File

@ -0,0 +1,4 @@
builders:
- ssh-builder:
ssh-user-ip: foo@bar:22
command: echo foo