[jenkinscat-docs] master: Updated, added comments, sync with devel version. (1ad3139)

immanetize at fedoraproject.org immanetize at fedoraproject.org
Fri Feb 6 07:39:41 UTC 2015


Repository : http://git.fedorahosted.org/cgit/jenkinscat-docs.git

On branch  : master

>---------------------------------------------------------------

commit 1ad3139bc280a0c1caee133a45fcf0840aa1f499
Author: Pavel Tisnovsky <ptisnovs at redhat.com>
Date:   Tue Nov 18 12:10:12 2014 +0100

    Updated, added comments, sync with devel version.


>---------------------------------------------------------------

 ChangeLog                       |    5 +++++
 tools/create_books_clj_file.lua |   32 ++++++++++++++++++++++++++------
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ef3a667..016efea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-18  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* tools/create_books_clj_file.lua:
+	Updated, added comments, sync with devel version.
+
 2014-11-13  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/jenkinscat/server.clj:
diff --git a/tools/create_books_clj_file.lua b/tools/create_books_clj_file.lua
index de48379..bc247e1 100644
--- a/tools/create_books_clj_file.lua
+++ b/tools/create_books_clj_file.lua
@@ -36,6 +36,16 @@ end
 
 
 --
+-- Tests if the given string ends with the specified suffix.
+--
+function string.endsWith(str, suffix)
+    local substring = string.sub(str, -string.len(suffix))
+    return suffix == "" or substring == suffix
+end
+
+
+
+--
 -- Read input file and return its content as a string.
 --
 function readInputFile(inputFileName)
@@ -201,6 +211,7 @@ function readDocumentInfoFromPublicanCfg(jobDirectory)
 
     local fin = io.open(publicanCfgFile, "r")
     if fin == nil then
+        print("Warning: can not read file " .. publicanCfgFile)
         return "", "", "", "", ""
     end
     fin:close()
@@ -236,12 +247,15 @@ function readDocumentInfoFromPublicanCfg(jobDirectory)
     return documentType, productName, productVersion, documentName, condition
 end
 
+
+
 --
 --
 --
-function fetchDocumentTitle(jobDirectory, docname)
+function fetchDocumentTitleFromXML(jobDirectory, docname)
     local workspace = jobDirectory .. "/workspace/en-US"
     local command = "cd \"" .. workspace .. "\"; xmllint --xinclude --postvalid \"" .. docname .. ".xml\" 2>/dev/null | xmlstarlet sel -t -v \"//bookinfo/title|//articleinfo/title\" 2>/dev/null"
+    print(command)
     local handle = io.popen(command)
     local result = handle:read("*a")
     handle:close()
@@ -251,7 +265,7 @@ end
 --
 --
 --
-function fetchProductName(jobDirectory, docname)
+function fetchProductNameFromXML(jobDirectory, docname)
     local workspace = jobDirectory .. "/workspace/en-US"
     local command = "cd \"" .. workspace .. "\"; xmllint --xinclude --postvalid \"" .. docname .. ".xml\" 2>/dev/null | xmlstarlet sel -t -v \"//bookinfo/productname|//articleinfo/productname\" 2>/dev/null"
     local handle = io.popen(command)
@@ -263,7 +277,7 @@ end
 --
 --
 --
-function fetchProductVersion(jobDirectory, docname, condition)
+function fetchProductVersionFromXML(jobDirectory, docname, condition)
     local workspace = jobDirectory .. "/workspace/en-US"
 
     local command = nil
@@ -299,6 +313,7 @@ function getJobTitleTypeAndProduct(jobDirectory)
     local documentName
     local condition
 
+    print("Processing job " .. jobDirectory)
     documentType, productName, productVersion, documentName, condition = readDocumentInfoFromPublicanCfg(jobDirectory)
 
     if documentName == nil then
@@ -309,14 +324,15 @@ function getJobTitleTypeAndProduct(jobDirectory)
         end
     end
 
-    local documentTitle = fetchDocumentTitle(jobDirectory, documentName)
+    local documentTitle = fetchDocumentTitleFromXML(jobDirectory, documentName)
+    print(documentTitle)
 
     if productName == nil then
-        productName = fetchProductName(jobDirectory, documentName)
+        productName = fetchProductNameFromXML(jobDirectory, documentName)
     end
 
     if productVersion == nil then
-        productVersion = fetchProductVersion(jobDirectory, documentName, condition)
+        productVersion = fetchProductVersionFromXML(jobDirectory, documentName, condition)
     end
 
     return documentTitle, documentType, productName, productVersion
@@ -387,10 +403,12 @@ end
 
 
 --
+-- Add job directory and work directory information to each job.
 --
 function addJobDirectories(allJobs)
     for i, job in ipairs(allJobs) do
         job.directory = jenkins_dir .. "jobs/" .. job.name
+        job.workDirectory = jenkins_dir .. "workspace/" .. job.name
     end
 end
 
@@ -574,6 +592,8 @@ function main()
     addArtifactInfo(normalJobs)
 end
 
+
+
 --
 -- Rule the world!
 --



More information about the docs-commits mailing list