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 pathbuild.groovy
104 lines (95 loc) · 2.31 KB
/
build.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
#!/usr/bin/env groovy
import com.concur.*;
workflowDoc = '''
title: Build
overview: Includes workflows for running various language independent build tools.
additional_resources:
- name: Magefile GitHub
url: https://github.com/magefile/mage
- name: Magefile Official Docs
url: https://magefile.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:
mage:
buildImage: "quay.io/example/mage"
branches:
patterns:
feature: .+
branches:
feature:
steps:
- build:
- mage:
- build:
- mage:
target: Docker
'''
concurUtil = new com.concur.Util()
/*
description: Execute mage targets.
parameters:
- type: String
name: buildImage
description: Docker image that has Mage installed.
- type: String
name: target
description: The mage target to execute.
- type: String
name: mageFileDir
default: '.'
description: The directory containing your magefile.
example: |
branches:
feature:
steps:
- build:
# Simple
- mage:
# Advanced
- mage:
target: Install
*/
public mage(Map yml, Map args) {
String buildImage = args?.buildImage ?: yml.tools?.mage?.buildImage
String target = args?.target ?: yml.tools?.mage?.target
String mageFileDir = args?.mageFileDir ?: yml.tools?.mage?.mageFileDir ?: '.'
def cmd = "mage"
if (target) {
cmd = "$cmd $target"
}
dir(mageFileDir) {
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 'mage':
def mageTarget = args?.target ?: yml.tools?.mage?.target
return mageTarget ? "build: mage: ${mageTarget}" : "build: mage"
}
}
public tests(Map yml, Map args) {
String workflowName = 'build'
println "Testing $workflowName"
}
return this;