homebrew-core/Formula/jenkins-lts.rb

70 lines
2.0 KiB
Ruby

class JenkinsLts < Formula
desc "Extendable open-source CI server"
homepage "https://jenkins.io/index.html#stable"
url "https://get.jenkins.io/war-stable/2.263.4/jenkins.war"
sha256 "1d4a7409784236a84478b76f3f2139939c0d7a3b4b2e53b1fcef400c14903ab6"
license "MIT"
livecheck do
url "https://get.jenkins.io/war-stable/"
regex(%r{href=.*?v?(\d+(?:\.\d+)+)/?["' >]}i)
end
bottle :unneeded
depends_on "openjdk@11"
def install
system "#{Formula["openjdk@11"].opt_bin}/jar", "xvf", "jenkins.war"
libexec.install "jenkins.war", "WEB-INF/lib/cli-#{version}.jar"
bin.write_jar_script libexec/"jenkins.war", "jenkins-lts", java_version: "11"
bin.write_jar_script libexec/"cli-#{version}.jar", "jenkins-lts-cli", java_version: "11"
end
def caveats
<<~EOS
Note: When using launchctl the port will be 8080.
EOS
end
plist_options manual: "jenkins-lts"
def plist
<<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{Formula["openjdk@11"].opt_bin}/java</string>
<string>-Dmail.smtp.starttls.enable=true</string>
<string>-jar</string>
<string>#{opt_libexec}/jenkins.war</string>
<string>--httpListenAddress=127.0.0.1</string>
<string>--httpPort=8080</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
test do
ENV["JENKINS_HOME"] = testpath
ENV.prepend "_JAVA_OPTIONS", "-Djava.io.tmpdir=#{testpath}"
port = free_port
fork do
exec "#{bin}/jenkins-lts --httpPort=#{port}"
end
sleep 60
output = shell_output("curl localhost:#{port}/")
assert_match(/Welcome to Jenkins!|Unlock Jenkins|Authentication required/, output)
end
end