homebrew-core/Formula/jenkins-lts.rb

72 lines
2.1 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.277.4/jenkins.war"
sha256 "26b278064393befa74f543d23050ca08589a6c14207cac06a0fbf6994113e7a7"
license "MIT"
livecheck do
url "https://www.jenkins.io/download/"
regex(%r{href=.*?/war-stable/v?(\d+(?:\.\d+)+)/jenkins\.war}i)
end
bottle do
sha256 cellar: :any_skip_relocation, all: "5c2d01259d112b58905968cd2a0312e67f8185ca06277d49b9cb2eb3718c2c82"
end
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