This repository has been archived by the owner on Feb 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocumentation.groovy
105 lines (93 loc) · 2.68 KB
/
documentation.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env groovy
import com.concur.*;
workflowDoc = '''
title: Documentation
overview: Includes workflows for running various language independent documentation generator tools.
additional_resources:
- name: Mkdocs
url: http://www.mkdocs.org
tools:
- type: String
name: buildImage
section: mage
description: Docker image that has Mage installed.
- type: String
name: target
section: mage
description: The mage target to execute.
- type: String
name: mageFileDir
section: mage
default: '.'
description: The directory containing your magefile.
full_example: |
pipelines:
tools:
mkdocs:
buildImage: "quay.io/example/mkdocs"
branches:
patterns:
feature: .+
branches:
feature:
steps:
- documentation:
- mkdocs:
'''
concurUtil = new com.concur.Util()
/*
description: Generate documentation using mkdocs
parameters:
- type: String
name: buildImage
description: Docker image that has mkdocs installed.
- type: String
name: command
default: build
description: Which mkdocs command to use, serve will not work, supported commands are build and gh-deploy.
- type: List
name: extraArgs
description: A list of extra arguments to append to the command.
example: |
branches:
feature:
steps:
- build:
# Simple
- mkdocs:
# Advanced
- mkdocs:
command: gh-deploy
*/
public mkdocs(Map yml, Map args) {
String buildImage = args?.buildImage ?: yml.tools?.mkdocs?.buildImage
String command = args?.command ?: yml.tools?.mkdocs?.command ?: 'build'
List extraArgs = args?.extraArgs ?: yml.tools?.mkdocs?.extraArgs ?: []
assert buildImage : 'Workflows :: documentation :: mkdocs :: No [buildImage] provided in [tools.mkdocs] or as a parameter to the documentation.mkdocs step.'
def unsupportedCommands = ['serve']
assert !(command in unsupportedCommands) : "Workflows :: documentation :: mkdocs :: ${unsupportedCommands.join(', ')} are unsupported commands for mkdocs"
def cmd = "mkdocs $command"
if (extraArgs) {
extraArgs.each { arg ->
cmd = "$cmd $arg"
}
}
docker.image(buildImage).inside {
sh concurUtil.mustacheReplaceAll(cmd)
}
}
/*
* Set the name of the stage dynamically.
*/
public getStageName(Map yml, Map args, String stepName) {
switch(stepName) {
case 'mkdocs':
String command = args?.command ?: yml.tools?.mkdocs?.command ?: 'build'
return "documentation: mkdocs: ${command}"
}
}
public tests(Map yml, Map args) {
String workflowName = 'documentation'
println "Testing $workflowName"
}
return this;