Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
If you've written a Gradle build script or a Jenkins pipeline, you've already written Apache Groovy — it's the scripting backbone of the JVM build ecosystem. Groovy layers optional typing, closures, and rich collection methods on top of Java, and any Java class works unchanged, which makes it ideal for gluing JVM code together fast. Recent Groovy releases added switch expressions, records, and sealed types to keep pace with modern Java. Test Groovy snippets here in a sandbox with a real terminal: output streams as it's produced, and reading from System.in waits for actual keystrokes, so trying a pipeline idea or a DSL trick takes seconds instead of a build cycle.
def reader = System.in.newReader()
print "Enter your name: "
def name = reader.readLine()
print "Enter three scores separated by spaces: "
def scores = reader.readLine().split(/\s+/).collect { it.toInteger() }
println "Thanks, ${name}!"
println "Average: ${scores.sum() / scores.size()}"
println "Sorted: ${scores.sort()}"
Debug the Groovy fragment inside a Jenkinsfile before committing it and waiting on a CI run, experiment with the collection methods (collect, findAll, inject, groupBy) that make Gradle scripts so terse, or use Groovy as a low-friction JVM scratchpad — no class declaration, no main method, just statements that run top to bottom. DevOps engineers maintaining pipeline libraries and Java developers curious about dynamic typing on the JVM both get answers here in one click.
Yes — the script is attached to an interactive terminal, so System.in.newReader().readLine() (or a Scanner) pauses and waits for your typed line before continuing. That lets you rehearse scripts that expect runtime input, something Jenkins snippet testers and most online runners can't do.
Pipeline steps are provided by Jenkins plugins, not the Groovy language, so they won't resolve in a plain Groovy runtime. What you can verify here is everything else in a Jenkinsfile: closures, string manipulation, list and map wrangling, regex matching, and control flow — usually where the actual bugs live.
No — @Grab needs network access to download artifacts, which the sandbox doesn't allow. You get the Groovy GDK plus the complete Java standard library, which covers file parsing, JSON-ish string handling, dates, regex, and collections without any external jars.
Main.groovygroovySystem.inprintln "Hello from Groovy!"
println "Welcome to XCODX Online Compiler!"
def message = "Groovy is dynamic!"
println message