diff --git a/Jenkinsfile b/Jenkinsfile index f53872d2..d664920f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -47,8 +47,7 @@ pipeline { // archive scenario-test reports in HTML format sh ''' - cd doc/scenarios - ./to-html + gw convertMarkdownToHtml ''' archiveArtifacts artifacts: 'doc/scenarios/*.html', allowEmptyArchive: true diff --git a/build.gradle b/build.gradle index 96b16673..547088f5 100644 --- a/build.gradle +++ b/build.gradle @@ -391,3 +391,45 @@ tasks.named("dependencyUpdates").configure { isNonStable(it.candidate.version) } } + + +// Generate HTML from Markdown scenario-test-reports using Pandoc: +tasks.register('convertMarkdownToHtml') { + description = 'Generates HTML from Markdown scenario-test-reports using Pandoc.' + group = 'Conversion' + + // Define the template file and input directory + def templateFile = file('doc/scenarios/template.html') + + // Task configuration and execution + doFirst { + // Check if pandoc is installed + try { + exec { + commandLine 'pandoc', '--version' + } + } catch (Exception) { + throw new GradleException("Pandoc is not installed or not found in the system path.") + } + + // Check if the template file exists + if (!templateFile.exists()) { + throw new GradleException("Template file 'doc/scenarios/template.html' not found.") + } + } + + doLast { + // Gather all Markdown files in the current directory + fileTree(dir: '.', include: 'doc/scenarios/*.md').each { file -> + // Corrected way to create the output file path + def outputFile = new File(file.parent, file.name.replaceAll(/\.md$/, '.html')) + + // Execute pandoc for each markdown file + exec { + commandLine 'pandoc', file.absolutePath, '--template', templateFile.absolutePath, '-o', outputFile.absolutePath + } + + println "Converted ${file.name} to ${outputFile.name}" + } + } +} diff --git a/doc/scenarios/to-html b/doc/scenarios/to-html deleted file mode 100755 index a66ff4d0..00000000 --- a/doc/scenarios/to-html +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# This script loops over all markdown (.md) files in the current directory -# and converts each to an HTML file using pandoc using template.html. - -# Origin of the template (GPL v3.0): -# https://github.com/ryangrose/easy-pandoc-templates/blob/master/html/easy_template.html - -for file in *.md; do - pandoc "$file" --template template.html -o "${file%.md}.html" -done -