Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titlemacroerrors.gradle
// Assumes acli is on your path and myconfluence is your defined confluence site configuration
// Tested with Gradle wrapper 7.3.3 and 8.5
// ./gradlew -b macroerrors.gradle -Pcli="acli myconfluence"

plugins { id("org.gint.atlassian") version "3.8.5" }

gint.verbose = true
def info = gint.getConfluenceHelper().getServerInfoWithVerify()  // verify server is available, otherwise end test

def space = gint.helper.getParameterValue('space', 'Examples')
def file = 'pageList.txt'

boolean result = gint.helper.runCmd(cmd: info.cli + " -a getPageList --space ${space} -f ${file}")
if (!result) {
    gint.addFailedMessage('getPageList failed!!!')
    gint.stopNow = true
}
def pageList = gint.helper.readFileToList(file)
// gint.helper.log('pageList', pageList)

// Define a task for each page in the list. 
// This makes it easy to run a test for a single page and to report on each page that fails individually.
pageList.each { entry ->
    def name = gint.helper.cleanTaskName(entry)
    gint.taskHelper.add('entry', [
        [action: 'renderPage', name: name,
            file: gint.getOutputFile(name),
            parameters: [
                space: space,
                title: entry,
            ],
            output: [
                failData: [
                    'placeholder/unknown-attachment',       // missing attachment like: src="/wiki/plugins/servlet/confluence/placeholder/unknown-attachment
                    'class="unresolved"',                   // missing link like: <a class="unresolved" href="#">missing-link</a>
                    'The included page could not be found', // include macro problem

                    'Unknown macro:',                       // missing macro
                    '<span class="error">',                 // general error
                    ~/(?:(?:<div class="error)|(?:<div class="[^"]*? aui-message-error))/, // covers both older style and newer style errors
                ],
            ]
        ]
    ])
}

...