Skip to content

Commit cfed61a

Browse files
committed
Groovy, just for fun
1 parent e4fb40f commit cfed61a

File tree

10 files changed

+550
-2
lines changed

10 files changed

+550
-2
lines changed

.buildkite/pipeline.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@
5959
key: "ruby",
6060
sdk_label: "sdk-ruby",
6161
app_label: "app-ruby"
62+
},
63+
{
64+
icon: ":java:",
65+
label: "Groovy",
66+
key: "groovy",
67+
sdk_label: "sdk-groovy",
68+
app_label: "app-groovy"
6269
}
6370
]
6471

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ FROM ruby:latest AS base
44
RUN apt-get update && apt-get install -y \
55
curl \
66
git \
7+
zip \
8+
unzip \
79
&& rm -rf /var/lib/apt/lists/*
810

911
# Use Bash, and fail on any error.
@@ -26,5 +28,18 @@ RUN mise install go@latest && mise use --global go@latest
2628
RUN pip install --no-cache-dir uv black
2729
RUN npm install -g nx
2830

31+
# Install SDKMAN! for Java-based languages.
32+
ENV SDKMAN_DIR="/usr/local/bin/sdkman"
33+
RUN curl -s https://get.sdkman.io | bash
34+
35+
# Install Java and Groovy.
36+
RUN bash -c "source $SDKMAN_DIR/bin/sdkman-init.sh && \
37+
sdk install java 17.0.10-tem && \
38+
sdk install groovy 4.0.26"
39+
40+
# ENV JAVA_HOME="$SDKMAN_DIR/candidates/java/current"
41+
# ENV GROOVY_HOME="$SDKMAN_DIR/candidates/groovy/current"
42+
# ENV PATH="$JAVA_HOME/bin:$GROOVY_HOME/bin:$PATH"
43+
2944
# Override the default command (irb).
3045
CMD ["true"]

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
A multi-language SDK for [Buildkite](https://buildkite.com)! 🪁
66

7-
Consumes the [Buildkite pipeline schema](https://github.com/buildkite/pipeline-schema) and generates and publishes packages for TypeScript, Python, Go, and Ruby.
7+
Consumes the [Buildkite pipeline schema](https://github.com/buildkite/pipeline-schema) and generates and publishes packages for TypeScript, Python, Go, Ruby, and Groovy.
88

99
## Installing and using the SDKs
1010

@@ -143,6 +143,31 @@ puts pipeline.to_json
143143
puts pipeline.to_yaml
144144
```
145145

146+
### Groovy
147+
148+
Install the package:
149+
150+
```bash
151+
# TODO.
152+
```
153+
154+
Use it in your program:
155+
156+
```groovy
157+
import buildkite.Pipeline
158+
import buildkite.StepTypes
159+
160+
def pipeline = new Pipeline()
161+
162+
pipeline.addStep([
163+
label: "some-label",
164+
command: "echo 'Hello, world!'"
165+
])
166+
167+
print pipeline.toJSON()
168+
print pipeline.toYAML()
169+
```
170+
146171
## Development
147172

148173
### Prerequisites
@@ -160,6 +185,15 @@ brew bundle
160185
mise install
161186
```
162187

188+
For Groovy, you'll need to set up your Java environment -- we recommend [SDKMAN!](https://sdkman.io/)):
189+
190+
```bash
191+
curl -s "https://get.sdkman.io" | bash
192+
source "$HOME/.sdkman/bin/sdkman-init.sh"
193+
sdk install java 17.0.10-tem
194+
sdk install groovy 4.0.26
195+
```
196+
163197
If you hit any rough edges during development, please file an issue. Thanks!
164198

165199
### Useful commands

apps/groovy/main.groovy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import buildkite.Pipeline
2+
import buildkite.StepTypes
3+
4+
def pipeline = new Pipeline()
5+
6+
pipeline.addStep([
7+
label: "some-label",
8+
command: "echo 'Hello, world!'"
9+
])
10+
11+
print pipeline.toJSON()

apps/groovy/project.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "app-groovy",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"projectType": "application",
5+
"sourceRoot": "apps/groovy/src",
6+
"targets": {
7+
"install": {
8+
"executor": "nx:run-commands",
9+
"options": {
10+
"commands": [],
11+
"cwd": "apps/groovy",
12+
"parallel": false
13+
}
14+
},
15+
"clean": {
16+
"executor": "nx:run-commands",
17+
"options": {
18+
"commands": [],
19+
"cwd": "apps/groovy"
20+
},
21+
"cache": false
22+
},
23+
"run": {
24+
"executor": "nx:run-commands",
25+
"options": {
26+
"commands": ["groovy -classpath ../../sdk/groovy main.groovy"],
27+
"cwd": "apps/groovy",
28+
"parallel": false
29+
},
30+
"dependsOn": ["install"]
31+
},
32+
"test": {
33+
"executor": "nx:run-commands",
34+
"outputs": [],
35+
"options": {
36+
"commands": [],
37+
"cwd": "apps/groovy",
38+
"parallel": false
39+
},
40+
"dependsOn": ["install"]
41+
}
42+
}
43+
}

project.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"app-python:install",
77
"app-go:install",
88
"app-ruby:install",
9+
"app-groovy:install",
910
"sdk-typescript:install",
1011
"sdk-python:install",
1112
"sdk-go:install",
@@ -118,7 +119,8 @@
118119
"app-typescript:run",
119120
"app-python:run",
120121
"app-go:run",
121-
"app-ruby:run"
122+
"app-ruby:run",
123+
"app-groovy:run"
122124
]
123125
},
124126
"publish:all": {
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
package buildkite
2+
3+
/**
4+
* Buildkite Environment Variables
5+
* A Groovy enum equivalent to the TypeScript EnvironmentVariable
6+
*/
7+
enum EnvironmentVariable {
8+
/**
9+
* Always `true`
10+
*/
11+
BUILDKITE("BUILDKITE"),
12+
13+
/**
14+
* The agent session token for the job. The variable is read by the agent `artifact` and `meta-data` commands.
15+
*/
16+
BUILDKITE_AGENT_ACCESS_TOKEN("BUILDKITE_AGENT_ACCESS_TOKEN"),
17+
18+
/**
19+
* The value of the `debug` agent configuration option.
20+
*/
21+
BUILDKITE_AGENT_DEBUG("BUILDKITE_AGENT_DEBUG"),
22+
23+
/**
24+
* The value of the `disconnect-after-job` agent configuration option.
25+
*/
26+
BUILDKITE_AGENT_DISCONNECT_AFTER_JOB("BUILDKITE_AGENT_DISCONNECT_AFTER_JOB"),
27+
28+
/**
29+
* The value of the `disconnect-after-idle-timeout` agent configuration option.
30+
*/
31+
BUILDKITE_AGENT_DISCONNECT_AFTER_IDLE_TIMEOUT("BUILDKITE_AGENT_DISCONNECT_AFTER_IDLE_TIMEOUT"),
32+
33+
/**
34+
* The value of the `endpoint` agent configuration option.
35+
*/
36+
BUILDKITE_AGENT_ENDPOINT("BUILDKITE_AGENT_ENDPOINT"),
37+
38+
/**
39+
* A list of the experimental agent features that are currently enabled.
40+
*/
41+
BUILDKITE_AGENT_EXPERIMENT("BUILDKITE_AGENT_EXPERIMENT"),
42+
43+
/**
44+
* The value of the `health-check-addr` agent configuration option.
45+
*/
46+
BUILDKITE_AGENT_HEALTH_CHECK_ADDR("BUILDKITE_AGENT_HEALTH_CHECK_ADDR"),
47+
48+
/**
49+
* The UUID of the agent.
50+
*/
51+
BUILDKITE_AGENT_ID("BUILDKITE_AGENT_ID"),
52+
53+
/**
54+
* The value of each agent tag.
55+
*/
56+
BUILDKITE_AGENT_META_DATA_("BUILDKITE_AGENT_META_DATA_"),
57+
58+
/**
59+
* The name of the agent that ran the job.
60+
*/
61+
BUILDKITE_AGENT_NAME("BUILDKITE_AGENT_NAME"),
62+
63+
/**
64+
* The process ID of the agent.
65+
*/
66+
BUILDKITE_AGENT_PID("BUILDKITE_AGENT_PID"),
67+
68+
/**
69+
* The artifact paths to upload after the job, if any have been specified.
70+
*/
71+
BUILDKITE_ARTIFACT_PATHS("BUILDKITE_ARTIFACT_PATHS"),
72+
73+
/**
74+
* The path where artifacts will be uploaded.
75+
*/
76+
BUILDKITE_ARTIFACT_UPLOAD_DESTINATION("BUILDKITE_ARTIFACT_UPLOAD_DESTINATION"),
77+
78+
/**
79+
* The path to the directory containing the `buildkite-agent` binary.
80+
*/
81+
BUILDKITE_BIN_PATH("BUILDKITE_BIN_PATH"),
82+
83+
/**
84+
* The branch being built.
85+
*/
86+
BUILDKITE_BRANCH("BUILDKITE_BRANCH"),
87+
88+
/**
89+
* The path where the agent has checked out your code for this build.
90+
*/
91+
BUILDKITE_BUILD_CHECKOUT_PATH("BUILDKITE_BUILD_CHECKOUT_PATH"),
92+
93+
/**
94+
* The name of the user who authored the commit being built.
95+
*/
96+
BUILDKITE_BUILD_AUTHOR("BUILDKITE_BUILD_AUTHOR"),
97+
98+
/**
99+
* The notification email of the user who authored the commit being built.
100+
*/
101+
BUILDKITE_BUILD_AUTHOR_EMAIL("BUILDKITE_BUILD_AUTHOR_EMAIL"),
102+
103+
/**
104+
* The name of the user who created the build.
105+
*/
106+
BUILDKITE_BUILD_CREATOR("BUILDKITE_BUILD_CREATOR"),
107+
108+
/**
109+
* The notification email of the user who created the build.
110+
*/
111+
BUILDKITE_BUILD_CREATOR_EMAIL("BUILDKITE_BUILD_CREATOR_EMAIL"),
112+
113+
/**
114+
* A colon separated list of non-private team slugs that the build creator belongs to.
115+
*/
116+
BUILDKITE_BUILD_CREATOR_TEAMS("BUILDKITE_BUILD_CREATOR_TEAMS"),
117+
118+
/**
119+
* The UUID of the build.
120+
*/
121+
BUILDKITE_BUILD_ID("BUILDKITE_BUILD_ID"),
122+
123+
/**
124+
* The build number.
125+
*/
126+
BUILDKITE_BUILD_NUMBER("BUILDKITE_BUILD_NUMBER"),
127+
128+
/**
129+
* The value of the `build-path` agent configuration option.
130+
*/
131+
BUILDKITE_BUILD_PATH("BUILDKITE_BUILD_PATH"),
132+
133+
/**
134+
* The url for this build on Buildkite.
135+
*/
136+
BUILDKITE_BUILD_URL("BUILDKITE_BUILD_URL"),
137+
138+
/**
139+
* The value of the `cancel-grace-period` agent configuration option in seconds.
140+
*/
141+
BUILDKITE_CANCEL_GRACE_PERIOD("BUILDKITE_CANCEL_GRACE_PERIOD"),
142+
143+
/**
144+
* The value of the `cancel-signal` agent configuration option.
145+
*/
146+
BUILDKITE_CANCEL_SIGNAL("BUILDKITE_CANCEL_SIGNAL"),
147+
148+
/**
149+
* Whether the build should perform a clean checkout.
150+
*/
151+
BUILDKITE_CLEAN_CHECKOUT("BUILDKITE_CLEAN_CHECKOUT"),
152+
153+
/**
154+
* The UUID value of the cluster.
155+
*/
156+
BUILDKITE_CLUSTER_ID("BUILDKITE_CLUSTER_ID"),
157+
158+
/**
159+
* The command that will be run for the job.
160+
*/
161+
BUILDKITE_COMMAND("BUILDKITE_COMMAND"),
162+
163+
/**
164+
* The opposite of the value of the `no-command-eval` agent configuration option.
165+
*/
166+
BUILDKITE_COMMAND_EVAL("BUILDKITE_COMMAND_EVAL"),
167+
168+
/**
169+
* The exit code from the last command run in the command hook.
170+
*/
171+
BUILDKITE_COMMAND_EXIT_STATUS("BUILDKITE_COMMAND_EXIT_STATUS"),
172+
173+
/**
174+
* The git commit object of the build.
175+
*/
176+
BUILDKITE_COMMIT("BUILDKITE_COMMIT"),
177+
178+
/**
179+
* The path to the agent config file.
180+
*/
181+
BUILDKITE_CONFIG_PATH("BUILDKITE_CONFIG_PATH"),
182+
183+
/**
184+
* The path to the file containing the job's environment variables.
185+
*/
186+
BUILDKITE_ENV_FILE("BUILDKITE_ENV_FILE"),
187+
188+
// More environment variables would be added here...
189+
190+
/**
191+
* Always `true`.
192+
*/
193+
CI("CI")
194+
195+
private final String value
196+
197+
private EnvironmentVariable(String value) {
198+
this.value = value
199+
}
200+
201+
@Override
202+
String toString() {
203+
return value
204+
}
205+
}

0 commit comments

Comments
 (0)