summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlia Meerovich <imeerovi@redhat.com>2015-04-28 14:47:49 +0300
committerIlia Meerovich <imeerovi@redhat.com>2015-06-03 08:16:19 +0300
commit2b5f9344b7b1ceae7bf804ee00ec17197768446c (patch)
tree542c3a1e1d27bd831db9c30e8f22e15c525e61dd
parent29a09458d2d4b2407e1efbeb29f4d24c7f626101 (diff)
downloadpython-jenkins-job-builder-2b5f9344b7b1ceae7bf804ee00ec17197768446c.tar.gz
python-jenkins-job-builder-2b5f9344b7b1ceae7bf804ee00ec17197768446c.tar.xz
python-jenkins-job-builder-2b5f9344b7b1ceae7bf804ee00ec17197768446c.zip
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
-rw-r--r--jenkins_jobs/modules/builders.py23
-rw-r--r--setup.cfg1
-rw-r--r--tests/builders/fixtures/ssh-builder.xml9
-rw-r--r--tests/builders/fixtures/ssh-builder.yaml4
4 files changed, 37 insertions, 0 deletions
diff --git a/jenkins_jobs/modules/builders.py b/jenkins_jobs/modules/builders.py
index 2b5a5eeb..c576833d 100644
--- a/jenkins_jobs/modules/builders.py
+++ b/jenkins_jobs/modules/builders.py
@@ -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.
diff --git a/setup.cfg b/setup.cfg
index caba307a..628eb8e8 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -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 =
diff --git a/tests/builders/fixtures/ssh-builder.xml b/tests/builders/fixtures/ssh-builder.xml
new file mode 100644
index 00000000..fa88cc45
--- /dev/null
+++ b/tests/builders/fixtures/ssh-builder.xml
@@ -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>
diff --git a/tests/builders/fixtures/ssh-builder.yaml b/tests/builders/fixtures/ssh-builder.yaml
new file mode 100644
index 00000000..4f33897b
--- /dev/null
+++ b/tests/builders/fixtures/ssh-builder.yaml
@@ -0,0 +1,4 @@
+builders:
+ - ssh-builder:
+ ssh-user-ip: foo@bar:22
+ command: echo foo \ No newline at end of file