homebrew-core/Formula/jenkins-lts.rb

51 lines
1.5 KiB
Ruby

class JenkinsLts < Formula
desc "Extendable open-source CI server"
homepage "https://www.jenkins.io/index.html#stable"
url "https://get.jenkins.io/war-stable/2.361.2/jenkins.war"
sha256 "411a79c7e0d5082745071e261081346aa4ca27f649feb041756d1d27a983dbf6"
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: "933532fba821fd8fcc7baa79c09c859d4b6ec4778ef374b076385da2fd2f7292"
end
depends_on "openjdk@17"
def install
system "#{Formula["openjdk@17"].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: "17"
bin.write_jar_script libexec/"cli-#{version}.jar", "jenkins-lts-cli", java_version: "17"
end
def caveats
<<~EOS
Note: When using launchctl the port will be 8080.
EOS
end
service do
run [Formula["openjdk@17"].opt_bin/"java", "-Dmail.smtp.starttls.enable=true", "-jar", opt_libexec/"jenkins.war",
"--httpListenAddress=127.0.0.1", "--httpPort=8080"]
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