Jenkins is an open-source server capable of Continuous Integration and Continues Deployment (CI/CD). Jenkin is basically a java based application. Jenkins uses a wrapper around Jetty that implements the Winstone command line interface.
Here is an example of a shell script that can deploy, run and stop Jenkins on an AWS EC2 instance.
Before that there is some information, this script is tested on RED HAT 8 on en EC2 instance.
You need to have java installed in this machine. For example, for this machine following is the java version -
Following is the shell script with options to start and stop Jenkins. When you start Jenkins it starts Jetty container. To stop Jenkins you simply have to kill the java process.
cat /etc/*-release NAME="Red Hat Enterprise Linux" VERSION="8.0 (Ootpa)" ID="rhel" ID_LIKE="fedora" VERSION_ID="8.0" PLATFORM_ID="platform:el8" PRETTY_NAME="Red Hat Enterprise Linux 8.0 (Ootpa)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:redhat:enterprise_linux:8.0:GA" HOME_URL="https://www.redhat.com/" BUG_REPORT_URL="https://bugzilla.redhat.com/" REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8" REDHAT_BUGZILLA_PRODUCT_VERSION=8.0 REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux" REDHAT_SUPPORT_PRODUCT_VERSION="8.0" Red Hat Enterprise Linux release 8.0 (Ootpa) Red Hat Enterprise Linux release 8.0 (Ootpa)
java -version openjdk version "1.8.0_232" OpenJDK Runtime Environment (build 1.8.0_232-b09) OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)
#!/bin/bash clear echo "Enter your choice $0 start|stop :" $1 function help() { echo "Please select an option " echo "enter $0 start to start Jenkin" echo "enter $0 stop to stop Jenkin" } function startJn() { echo "Initializing Jenkins" java -jar /opt/spark/jenkins/jenkins.war --httpPort=80 & JenkinPID=$! echo $jenkinPID } function stopJn() { echo "Your Java PID is" pidof java echo "Process killing initiated" kill -9 $(pidof java) }
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.