Create Pages programmatically with Job Macro
Last modified by Ilie Andriuta on 2026/06/02 17:54
| Create Pages programmatically with a Groovy script through Job Macro |
| Type | |
| Category | Other |
| Developed by | |
| Rating | |
| License | GNU Lesser General Public License 2.1 |
Table of contents
Description
The script is made for creating pages without a parent .
- First Install Job Macro;
- Create a page, edit it in Wiki/Source Mode and paste (modify the i<10000 with how many pages is needed), then Save the page:
{{job id="{{velocity}}$doc.fullName{{/velocity}}" start="true"}}
{{groovy}}
def logger = services.logging.getLogger(doc.getFullName());
for (int i=0;i<10000;i++) {
if (i % 100 == 0) {
logger.warn("Working on document ${i}")
}
def document = xwiki.getDocument("Main.${i}");
document.save();
}
{{/groovy}}
{{/job}}