Support for externaljob project-type for monitoring external jobs

Change-Id: I8904725f75d27180d44c55768605db7d67e79586
This commit is contained in:
Somay Jain 2015-07-21 17:19:10 +05:30
parent c61fe7d1e2
commit 92b7f446f9
8 changed files with 70 additions and 3 deletions

View File

@ -351,6 +351,7 @@ The bulk of the job definitions come from the following modules.
.. toctree::
:maxdepth: 2
project_externaljob
project_flow
project_freestyle
project_maven

View File

@ -0,0 +1,7 @@
.. _project_externaljob:
ExternalJob Project
===================
.. automodule:: project_externaljob
:members:

View File

@ -21,8 +21,8 @@ Example:
:Job Parameters:
* **project-type**:
Defaults to "freestyle", but "maven" as well as "multijob" or "flow"
can also be specified.
Defaults to "freestyle", but "maven" as well as "multijob", "flow" or
"externaljob" can also be specified.
* **defaults**:
Specifies a set of :ref:`defaults` to use for this job, defaults to

View File

@ -0,0 +1,44 @@
# Copyright 2015 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
The External Job Project module handles creating ExternalJob Jenkins projects.
You may specify ``externaljob`` in the ``project-type`` attribute of the
:ref:`Job` definition.
This type of job allows you to record the execution of a process run outside
Jenkins, even on a remote machine. This is designed so that you can use
Jenkins as a dashboard of your existing automation system.
Requires the Jenkins :jenkins-wiki:`External Monitor Job Type Plugin
<Monitoring+external+jobs>`.
Example:
.. literalinclude:: /../../tests/general/fixtures/project-type005.yaml
"""
import xml.etree.ElementTree as XML
import jenkins_jobs.modules.base
class ExternalJob(jenkins_jobs.modules.base.Base):
sequence = 0
def root_xml(self, data):
xml_parent = XML.Element('hudson.model.ExternalJob')
return xml_parent

View File

@ -38,6 +38,7 @@ warnerrors = True
console_scripts =
jenkins-jobs=jenkins_jobs.cmd:main
jenkins_jobs.projects =
externaljob=jenkins_jobs.modules.project_externaljob:ExternalJob
flow=jenkins_jobs.modules.project_flow:Flow
freestyle=jenkins_jobs.modules.project_freestyle:Freestyle
matrix=jenkins_jobs.modules.project_matrix:Matrix

View File

@ -42,7 +42,8 @@ from jenkins_jobs.xml_config import XmlJob
from jenkins_jobs.modules import (project_flow,
project_matrix,
project_maven,
project_multijob)
project_multijob,
project_externaljob)
def get_scenarios(fixtures_path, in_ext='yaml', out_ext='xml',
@ -140,6 +141,8 @@ class BaseTestCase(object):
project = project_flow.Flow(None)
elif (yaml_content['project-type'] == "multijob"):
project = project_multijob.MultiJob(None)
elif (yaml_content['project-type'] == "externaljob"):
project = project_externaljob.ExternalJob(None)
if project:
xml_project = project.root_xml(yaml_content)

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<hudson.model.ExternalJob>
<actions/>
<keepDependencies>false</keepDependencies>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<concurrentBuild>false</concurrentBuild>
<canRoam>true</canRoam>
</hudson.model.ExternalJob>

View File

@ -0,0 +1,2 @@
name: openstack-infra
project-type: externaljob