diff options
author | vbotay <vasilygorin@gmail.com> | 2017-10-23 17:01:23 +0300 |
---|---|---|
committer | Vasily Gorin <vasilygorin@gmail.com> | 2017-10-24 22:01:00 +0000 |
commit | 5c05925d00c8735501cc8a63432054adcf910d92 (patch) | |
tree | 3284cffffa722a1e0a0a1b26e55b18faf574b3cf | |
parent | a23f8bf8db087d6bdc7c56b8f217f696927350a8 (diff) | |
download | python-jenkins-job-builder-5c05925d00c8735501cc8a63432054adcf910d92.tar.gz python-jenkins-job-builder-5c05925d00c8735501cc8a63432054adcf910d92.tar.xz python-jenkins-job-builder-5c05925d00c8735501cc8a63432054adcf910d92.zip |
Add NodeJS executor build step
Currently there is no possibility to setup options for 'NodeJS Plugin'
https://wiki.jenkins.io/display/JENKINS/NodeJS+Plugin
But 'NodeJS Plugin' is widely used to get ability of executing JS in build step
So this patch introduces configuration options for 'Execute NodeJS script' build step.
Change-Id: Ie0a9863f235d4199a6de350036394b8d054eb1e9
-rw-r--r-- | jenkins_jobs/modules/builders.py | 28 | ||||
-rw-r--r-- | tests/builders/fixtures/nodejs-full.xml | 10 | ||||
-rw-r--r-- | tests/builders/fixtures/nodejs-full.yaml | 5 | ||||
-rw-r--r-- | tests/builders/fixtures/nodejs-minimal.xml | 8 | ||||
-rw-r--r-- | tests/builders/fixtures/nodejs-minimal.yaml | 3 |
5 files changed, 54 insertions, 0 deletions
diff --git a/jenkins_jobs/modules/builders.py b/jenkins_jobs/modules/builders.py index d893627f..12e72e67 100644 --- a/jenkins_jobs/modules/builders.py +++ b/jenkins_jobs/modules/builders.py @@ -4090,3 +4090,31 @@ def ansible_playbook(parser, xml_parent, data): XML.SubElement(value_elm, 'value').text = values.get('value', '') XML.SubElement(value_elm, 'hidden').text = str( values.get('hidden', False)).lower() + + +def nodejs(parser, xml_parent, data): + """yaml: nodejs + This plugin allows to execute NodeJS scripts as a job build step. + Requires the Jenkins :jenkins-wiki:`NodeJS Plugin <NodeJS+Plugin>`. + + :arg str name: NodeJS installation name + :arg str script: NodeJS script (required) + :arg str config-id: ID of npmrc config file, which is the + last field (a 32-digit hexadecimal code) of the path of URL visible + after you clicked the file under Jenkins Managed Files. + + Example: + + .. literalinclude:: + /../../tests/builders/fixtures/nodejs-executor001.yaml + + """ + nodejs = XML.SubElement(xml_parent, + 'jenkins.plugins.nodejs.NodeJSCommandInterpreter') + mapping = [('script', 'command', None)] + + mapping_opt = [('name', 'nodeJSInstallationName', None), + ('config-id', 'configId', None)] + + convert_mapping_to_xml(nodejs, data, mapping, fail_required=True) + convert_mapping_to_xml(nodejs, data, mapping_opt, fail_required=False) diff --git a/tests/builders/fixtures/nodejs-full.xml b/tests/builders/fixtures/nodejs-full.xml new file mode 100644 index 00000000..47a9c8b8 --- /dev/null +++ b/tests/builders/fixtures/nodejs-full.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <builders> + <jenkins.plugins.nodejs.NodeJSCommandInterpreter> + <command>console.log('Some output');</command> + <nodeJSInstallationName>NodeJS_8.1</nodeJSInstallationName> + <configId>e3757442-7c21-4a65-a1ff-6c70f5c6df34</configId> + </jenkins.plugins.nodejs.NodeJSCommandInterpreter> + </builders> +</project> diff --git a/tests/builders/fixtures/nodejs-full.yaml b/tests/builders/fixtures/nodejs-full.yaml new file mode 100644 index 00000000..a519614c --- /dev/null +++ b/tests/builders/fixtures/nodejs-full.yaml @@ -0,0 +1,5 @@ +builders: + - nodejs: + name: "NodeJS_8.1" + script: "console.log('Some output');" + config-id: "e3757442-7c21-4a65-a1ff-6c70f5c6df34" diff --git a/tests/builders/fixtures/nodejs-minimal.xml b/tests/builders/fixtures/nodejs-minimal.xml new file mode 100644 index 00000000..df8bfa80 --- /dev/null +++ b/tests/builders/fixtures/nodejs-minimal.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <builders> + <jenkins.plugins.nodejs.NodeJSCommandInterpreter> + <command>console.log('Some output');</command> + </jenkins.plugins.nodejs.NodeJSCommandInterpreter> + </builders> +</project> diff --git a/tests/builders/fixtures/nodejs-minimal.yaml b/tests/builders/fixtures/nodejs-minimal.yaml new file mode 100644 index 00000000..e64bfc6e --- /dev/null +++ b/tests/builders/fixtures/nodejs-minimal.yaml @@ -0,0 +1,3 @@ +builders: + - nodejs: + script: "console.log('Some output');" |