64 lines
1.8 KiB
Ruby
64 lines
1.8 KiB
Ruby
class Jenkins < Formula
|
|
desc "Extendable open source continuous integration server"
|
|
homepage "https://www.jenkins.io/"
|
|
url "https://get.jenkins.io/war/2.383/jenkins.war"
|
|
sha256 "a871248a347a950c468ff119dea364fc477c679c743637fb128af8e95f51e559"
|
|
license "MIT"
|
|
|
|
livecheck do
|
|
url "https://www.jenkins.io/download/"
|
|
regex(%r{href=.*?/war/v?(\d+(?:\.\d+)+)/jenkins\.war}i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, all: "6fe3f83d57d9aa64a063e41ae233cefb7b98d232b3bf8b1d9f009be2a1e383af"
|
|
end
|
|
|
|
head do
|
|
url "https://github.com/jenkinsci/jenkins.git"
|
|
depends_on "maven" => :build
|
|
end
|
|
|
|
depends_on "openjdk@17"
|
|
|
|
def install
|
|
if build.head?
|
|
system "mvn", "clean", "install", "-pl", "war", "-am", "-DskipTests"
|
|
else
|
|
system "#{Formula["openjdk@17"].opt_bin}/jar", "xvf", "jenkins.war"
|
|
end
|
|
libexec.install Dir["**/jenkins.war", "**/cli-#{version}.jar"]
|
|
bin.write_jar_script libexec/"jenkins.war", "jenkins", java_version: "17"
|
|
bin.write_jar_script libexec/"cli-#{version}.jar", "jenkins-cli", java_version: "17"
|
|
|
|
(var/"log/jenkins").mkpath
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
Note: When using launchctl the port will be 8080.
|
|
EOS
|
|
end
|
|
|
|
service do
|
|
run [opt_bin/"jenkins", "--httpListenAddress=127.0.0.1", "--httpPort=8080"]
|
|
keep_alive true
|
|
log_path var/"log/jenkins/output.log"
|
|
error_log_path var/"log/jenkins/error.log"
|
|
end
|
|
|
|
test do
|
|
ENV["JENKINS_HOME"] = testpath
|
|
ENV.prepend "_JAVA_OPTIONS", "-Djava.io.tmpdir=#{testpath}"
|
|
|
|
port = free_port
|
|
fork do
|
|
exec "#{bin}/jenkins --httpPort=#{port}"
|
|
end
|
|
sleep 60
|
|
|
|
output = shell_output("curl localhost:#{port}/")
|
|
assert_match(/Welcome to Jenkins!|Unlock Jenkins|Authentication required/, output)
|
|
end
|
|
end
|