81 lines
2.3 KiB
Ruby
81 lines
2.3 KiB
Ruby
class Jenkins < Formula
|
|
desc "Extendable open source continuous integration server"
|
|
homepage "https://jenkins.io/"
|
|
url "http://mirrors.jenkins.io/war/2.295/jenkins.war"
|
|
sha256 "0c5e985cdb434fe8932c07f9f30e5e369bf6892a51c6b8431ffa4fa8509dd604"
|
|
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: "d9ea73a8888f22e79ecd28ddcd5986eb8ab7897891c0d91886732de3fb484d0e"
|
|
end
|
|
|
|
head do
|
|
url "https://github.com/jenkinsci/jenkins.git"
|
|
depends_on "maven" => :build
|
|
end
|
|
|
|
depends_on "openjdk@11"
|
|
|
|
def install
|
|
if build.head?
|
|
system "mvn", "clean", "install", "-pl", "war", "-am", "-DskipTests"
|
|
else
|
|
system "#{Formula["openjdk@11"].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: "11"
|
|
bin.write_jar_script libexec/"cli-#{version}.jar", "jenkins-cli", java_version: "11"
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
Note: When using launchctl the port will be 8080.
|
|
EOS
|
|
end
|
|
|
|
plist_options manual: "jenkins"
|
|
|
|
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 --httpPort=#{port}"
|
|
end
|
|
sleep 60
|
|
|
|
output = shell_output("curl localhost:#{port}/")
|
|
assert_match(/Welcome to Jenkins!|Unlock Jenkins|Authentication required/, output)
|
|
end
|
|
end
|