Last active
April 12, 2019 21:46
-
-
Save jjam3774/dd2641e7f86b062184f2 to your computer and use it in GitHub Desktop.
This downloads files then it creates an war file and finally bundles it up in an rpm using fpm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'open-uri' | |
puts "Downloading RPMs from Artifactory REPO!!!" | |
RPMS = [ "kube_yamls-1.0-1.x86_64.rpm", "mysql_docker_build-1.0-1.x86_64.rpm", "jboss_docker_build-1.0-1.x86_64.rpm", "Percona-Server-client-56-5.6.23-rel72.1.el6.x86_64.rpm", "Percona-Server-server-56-5.6.23-rel72.1.el6.x86_64.rpm", "Percona-Server-shared-56-5.6.23-rel72.1.el6.x86_64.rpm", "percona-xtrabackup-2.2.9-5067.el6.x86_64.rpm" ] | |
RPMS.each{|rpm| | |
open(rpm, 'wb') do |file| | |
puts "Downloading #{rpm}" | |
file << open("https://ccs-artifactory.com/artifactory/repo/#{rpm}").read | |
end | |
} | |
puts "building war file..".upcase | |
##################################### | |
# | |
# Defining instructions to create war file | |
# | |
##################################### | |
WARCOMMANDS = %Q( | |
if ! mvn -v | grep "Apache Maven"; then | |
sudo yum -y install maven | |
fi | |
if ! git --version; then | |
sudo yum -y install git | |
fi | |
#git clone https://ccs-gerrit.isc.com/centro | |
mvn -f centro/pom.xml clean install | |
) | |
##################################### | |
# | |
# Executing the instructions defined above | |
# | |
##################################### | |
IO.popen(WARCOMMANDS).each{|i| | |
puts i.upcase | |
} | |
puts "packing war into rpm.....".upcase | |
##################################### | |
# | |
# Defining instructions to pack war file into rpm | |
# | |
##################################### | |
FPMCOMMANDS = %Q( | |
#!/bin/bash | |
VERSION=3.4.2 | |
hash gcc 2>/dev/null || { | |
sudo yum install gcc -y | |
} | |
if ! rpm -q ruby-devel 2>/dev/null; then | |
sudo yum install -y ruby-devel | |
fi | |
hash rpmbuild 2>/dev/null || { | |
sudo yum install -y rpm-build | |
} | |
# /usr/local/bin must be added to root user's path or fpm will not be found. | |
PATH=$PATH:/usr/local/bin | |
hash fpm 2>/dev/null || { | |
sudo gem install fpm --no-ri --no-rdoc | |
} | |
if ! fpm --version | grep "1.4"; then | |
sudo gem update fpm | |
fi | |
###################################################################### | |
# | |
# BUILD WAR RPM | |
# | |
####################################################################### | |
fpm -s dir -t rpm -f -n centro_war_build -v 1.2 --epoch 0 centro/target/centro-1.0.war | |
) | |
############################## | |
# Executing the commands defined above | |
############################## | |
IO.popen(FPMCOMMANDS).each{|i| | |
puts "Making the changes...." | |
puts i.upcase | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment