Skip to content

Commit 8bcca09

Browse files
committed
First commit
1 parent 319725c commit 8bcca09

15 files changed

+535
-1
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.gradle
2+
.idea
3+
build
4+
gradle
5+
out

README.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,44 @@
1-
# multiline-regex-datacapture-filter
1+
# Multiline Regex Data Capture
2+
3+
This plugin captures Multiline Regex Key/Value data using a simple text format from a regular expression.
4+
5+
## Build
6+
7+
```
8+
gradle clean install
9+
```
10+
11+
## Install
12+
13+
```
14+
cp build/lib/multiline-regex-datacapture-filter-X.X.X.jar $RDECKBASE/libext
15+
```
16+
17+
## How to use
18+
19+
* Add a global o a step `Multiline Regex Data Capture` filter
20+
* Set the regex pattern to use, eg `^(.+?)\s*=\s*(.+)`
21+
* Set a name data (optional). If the pattern does not capture a key value, this parameter is required (example 2)
22+
* You can hide the original log output (checking the flag `Hide Output`)
23+
* You can print the result of the match (checking the flag `Log Data`)
24+
25+
## Examples
26+
27+
* Example 1: Capture a key/value list (see [examples/iterate-a-list.xml](examples/iterate-a-list.xml))
28+
29+
![alt_text](examples/example1-config.png)
30+
31+
![Example1](examples/example1-result.png)
32+
33+
* Example 2: Capture the result of a `ls -l` command (see [examples/capture-ls-command.xml](examples/capture-ls-command.xml))
34+
35+
![Example2](examples/example2-config.png)
36+
37+
![Example2](examples/example2-result.png)
38+
39+
* Example 3: Capture the result of a SQL query and iterate the captured variable using another step (see [examples/capture-ls-command.xml](examples/pretty-sql-print.xml))
40+
41+
![Example3](examples/example3-config.png)
42+
43+
![Example3](examples/example3-result.png)
44+

build.gradle

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
plugins {
2+
id 'groovy'
3+
id 'java'
4+
id 'pl.allegro.tech.build.axion-release' version '1.7.1'
5+
}
6+
7+
group 'com.rundeck.plugin'
8+
9+
ext.rundeckVersion='3.0.6-20180917'
10+
defaultTasks 'clean','build'
11+
ext.rundeckPluginVersion= '1.2'
12+
group 'com.rundeck.plugin'
13+
14+
scmVersion {
15+
ignoreUncommittedChanges = false
16+
tag {
17+
prefix = ''
18+
versionSeparator = ''
19+
def origDeserialize=deserialize
20+
//apend .0 to satisfy semver if the tag version is only X.Y
21+
deserialize = { config, position, tagName ->
22+
def orig = origDeserialize(config, position, tagName)
23+
if (orig.split('\\.').length < 3) {
24+
orig += ".0"
25+
}
26+
orig
27+
}
28+
}
29+
}
30+
project.version = scmVersion.version
31+
32+
sourceCompatibility = 1.8
33+
34+
35+
/**
36+
* Set this to a comma-separated list of full classnames of your implemented Rundeck
37+
* plugins.
38+
*/
39+
ext.pluginClassNames='com.rundeck.plugin.DataKeyFilterMultiLines'
40+
41+
42+
43+
44+
repositories {
45+
mavenCentral()
46+
}
47+
48+
configurations{
49+
//declare custom pluginLibs configuration to include only libs for this plugin
50+
pluginLibs
51+
52+
//declare compile to extend from pluginLibs so it inherits the dependencies
53+
compile{
54+
extendsFrom pluginLibs
55+
}
56+
}
57+
58+
59+
dependencies {
60+
compile 'org.codehaus.groovy:groovy-all:2.3.11'
61+
testCompile group: 'junit', name: 'junit', version: '4.12'
62+
63+
compile group: 'org.rundeck', name: 'rundeck-core', version: rundeckVersion
64+
testCompile "org.spockframework:spock-core:0.7-groovy-2.0"
65+
66+
}
67+
68+
69+
70+
// task to copy plugin libs to output/lib dir
71+
task copyToLib(type: Copy) {
72+
into "$buildDir/output/lib"
73+
from configurations.pluginLibs
74+
}
75+
76+
77+
jar {
78+
from "$buildDir/output"
79+
manifest {
80+
def libList = configurations.pluginLibs.collect{'lib/'+it.name}.join(' ')
81+
attributes 'Rundeck-Plugin-Classnames': pluginClassNames
82+
attributes 'Rundeck-Plugin-File-Version': version
83+
attributes 'Rundeck-Plugin-Version': rundeckPluginVersion, 'Rundeck-Plugin-Archive': 'true'
84+
attributes 'Rundeck-Plugin-Libs': "${libList}"
85+
attributes 'Main-Class': "io.github.valfadeev.rundeck.plugin.vault.VaultStoragePlugin"
86+
attributes 'Class-Path': "${libList} lib/rundeck-core-${rundeckVersion}.jar"
87+
}
88+
}
89+
//set jar task to depend on copyToLib
90+
jar.dependsOn(copyToLib)

examples/capture-ls-command.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<joblist>
2+
<job>
3+
<defaultTab>summary</defaultTab>
4+
<description></description>
5+
<executionEnabled>true</executionEnabled>
6+
<group>MultilinesRegex</group>
7+
<loglevel>INFO</loglevel>
8+
<name>capture-ls-command</name>
9+
<nodeFilterEditable>false</nodeFilterEditable>
10+
<scheduleEnabled>true</scheduleEnabled>
11+
<sequence keepgoing='false' strategy='node-first'>
12+
<command>
13+
<exec>ls -l</exec>
14+
<plugins>
15+
<LogFilter type='key-value-data-multilines'>
16+
<config>
17+
<hideOutput>false</hideOutput>
18+
<logData>true</logData>
19+
<name>ls</name>
20+
<regex>^\s*total\s[0-9]+\s*(.*)</regex>
21+
</config>
22+
</LogFilter>
23+
</plugins>
24+
</command>
25+
</sequence>
26+
</job>
27+
</joblist>

examples/example1-config.png

82.3 KB
Loading

examples/example1-result.png

140 KB
Loading

examples/example2-config.png

148 KB
Loading

examples/example2-result.png

350 KB
Loading

examples/example3-config.png

132 KB
Loading

examples/example3-result.png

191 KB
Loading

0 commit comments

Comments
 (0)