Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-44748] Ensure defunct files are removed from populating files (
#56) * Ensure defunct files are removed from populating files * kotlin support * Files Command, with some kotlin
- Loading branch information
Showing
13 changed files
with
179 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package hudson.plugins.accurev.cmd; | ||
|
||
import hudson.EnvVars; | ||
import hudson.FilePath; | ||
import hudson.Launcher; | ||
import hudson.model.TaskListener; | ||
import hudson.plugins.accurev.AccurevElement; | ||
import hudson.plugins.accurev.AccurevLauncher; | ||
import hudson.plugins.accurev.AccurevSCM; | ||
import hudson.plugins.accurev.XmlParserFactory; | ||
import hudson.plugins.accurev.parsers.xml.ParseFiles; | ||
import hudson.util.ArgumentListBuilder; | ||
import org.xmlpull.v1.XmlPullParserFactory; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.logging.Logger; | ||
|
||
public class FilesCmd extends Command { | ||
private static final Logger logger = Logger.getLogger(Login.class.getName()); | ||
|
||
public static List<AccurevElement> checkFiles( | ||
final AccurevSCM scm, | ||
final AccurevSCM.AccurevServer server, | ||
final EnvVars accurevEnv, | ||
final FilePath workspace, | ||
final TaskListener listener, | ||
final Launcher launcher, | ||
FilePath file) throws IOException { | ||
final String commandDescription = "files command"; | ||
final ArgumentListBuilder cmd = new ArgumentListBuilder(); | ||
cmd.add("files"); | ||
addServer(cmd, server); | ||
cmd.add("-fx"); | ||
cmd.add("-s", scm.getStream()); | ||
cmd.add("-l", file.getRemote()); | ||
|
||
// returns username | ||
final ArrayList<AccurevElement> list = new ArrayList<>(1); | ||
XmlPullParserFactory parser = XmlParserFactory.getFactory(); | ||
if (parser == null) throw new IOException("No XML Parser"); | ||
final Boolean filesFound = AccurevLauncher.runCommand(commandDescription, scm.getAccurevTool(), launcher, cmd, scm.getOptionalLock(), | ||
accurevEnv, workspace, listener, logger, parser, new ParseFiles(), list); | ||
if (filesFound == null) { | ||
throw new IOException("FilesCmd command failed."); | ||
} | ||
return list; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package hudson.plugins.accurev | ||
|
||
data class AccurevElement(val location: String, val status: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package hudson.plugins.accurev | ||
|
||
open class AccurevUtils { | ||
companion object { | ||
@JvmStatic fun cleanAccurevPath(str: String) = str.replace("\\", "/").removePrefix("/./") | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/kotlin/hudson/plugins/accurev/parsers/xml/ParseFiles.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package hudson.plugins.accurev.parsers.xml | ||
|
||
import hudson.plugins.accurev.AccurevElement | ||
import hudson.plugins.accurev.AccurevLauncher | ||
import hudson.plugins.accurev.AccurevUtils.Companion.cleanAccurevPath | ||
import org.xmlpull.v1.XmlPullParser | ||
|
||
class ParseFiles : AccurevLauncher.ICmdOutputXmlParser<Boolean, ArrayList<AccurevElement>> { | ||
override fun parse(parser: XmlPullParser?, context: ArrayList<AccurevElement>?): Boolean { | ||
while (parser?.next() != XmlPullParser.END_DOCUMENT) { | ||
if (parser?.eventType == XmlPullParser.START_TAG) { | ||
if ("element".equals(parser.name, ignoreCase = true)) { | ||
val location = cleanAccurevPath(parser.getAttributeValue("", "location")) | ||
val status = parser.getAttributeValue("", "status") | ||
context?.add(AccurevElement(location, status)) | ||
} | ||
} | ||
} | ||
return context != null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<div> | ||
<p>Enter the <b>Stream</b> name / <b>Workspace</b> name by typing.</p> | ||
<p>Input field offers auto complete suggestion</p> | ||
<p><b>Note:</b> Build will be generated from <b>Stream</b> or <b>Workspace</b>, as per the user's selection.</p> | ||
<p>Enter the <b>Stream</b> name / <b>Workspace</b> name by typing.</p> | ||
<p>Input field offers auto complete suggestion</p> | ||
<p><b>Note:</b> Build will be generated from <b>Stream</b> or <b>Workspace</b>, as per the user's selection.</p> | ||
</div> |