Skip to content

Commit 288f611

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

File tree

11 files changed

+577
-2
lines changed

11 files changed

+577
-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: 16 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,19 @@ 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+
# Set these for later use.
41+
ENV JAVA_HOME="$SDKMAN_DIR/candidates/java/current"
42+
ENV GROOVY_HOME="$SDKMAN_DIR/candidates/groovy/current"
43+
ENV PATH="$JAVA_HOME/bin:$GROOVY_HOME/bin:$PATH"
44+
2945
# Override the default command (irb).
3046
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/package-run.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# Initialize SDKMAN
4+
source "$HOME/.sdkman/bin/sdkman-init.sh"
5+
6+
# Use Java 17 from SDKMAN
7+
sdk use java 17.0.10-tem
8+
9+
# Use Groovy from SDKMAN
10+
sdk use groovy 4.0.26
11+
12+
# Get the absolute path of the SDK directory
13+
SDK_GROOVY_DIR=$(cd ../../sdk/groovy && pwd)
14+
15+
# Create output directory
16+
mkdir -p ../../out/apps/groovy
17+
18+
# Run the Groovy script with the SDK groovy directory in the classpath
19+
echo "Running Groovy script with classpath: $SDK_GROOVY_DIR"
20+
groovy -cp "$SDK_GROOVY_DIR" main.groovy
21+
22+
# If successful, show the generated files
23+
if [ $? -eq 0 ]; then
24+
echo "Success! Generated files:"
25+
ls -la ./out/apps/groovy/
26+
fi

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": {

0 commit comments

Comments
 (0)