Class Theory
Class Theory
https://www.youtube.com/praveensingampalli
#!/bin/bash
version="1.2.3.4"
for line in $(cat jiraid.txt)
do PREREQUISITE
curl -X PUT -u STEP 1 – create jiraid.txt
"your_atlassian_jira_username:yo
ur_atlassian_jira_token" --data
'{"update":{"labels":[{"add":"DEMO STEP 2 - Add your ticket id
_NEW"}]}}' -H "Content-Type:
application/json" STEP 3 – Create jira.sh and add beside code
https://singam.atlassian.net/rest/ap
i/3/issue/SA-1/comment STEP 4 – Replace the USERNAME and
done TOKEN from your Atlassian account
STEP 6 - ./ automation4.sh
AUTOMATION 5 - Playing With Dates And While loop
(FOR MAC)
#!/bin/bash
ONE=14d
Fourteendaysold=`date -v -${ONE}`
echo $Fourteendaysold
TWO=7d
sevendaysold=`date -v -${TWO}`
echo $sevendaysold
echo $Fourteendaysold and $sevendaysold are obtained
AUTOMATION5 - For Linux System
#!/bin/bash
may_date=`date -d '2023-04-01 +30 days' '+%Y-%m-%d'`
echo $may_date
TWO=2
april_date=`date -d '2023-04-03 -2 days' '+%Y-%m-%d'`
echo $april_date
AUTOMATION 6 - SendEmail To Team
/usr/sbin/sendmail -i -t <<
Subject: $1 server process status
From: Email1
To: Email2
Hi Team,
Please check for $1 service in TEST server
which has $3
process running with below list of KIT IDs
$2
Regards,
ShineInCareer
MESSAGE_END
Special Variables in Shell Vim hello.sh
sh hello.sh linkedin place good
echo $# -🡪 3
echo $? 🡪 Exit value of last command
1) $# Stores the number of echo $0. -🡪 Stores the first input [linkedin]
command-line arguments that were
passed to the shell program. echo $0 service in TEST server which has $3 $2
width="100%" align="justify"
STEP 2 – Add the beside shell script to automation7.sh
style="width: 100%; max-width: 1200px; background-color: #ffffff">
done
AUTOMATION 8 - Sonar/GitLab Rest API
curl -u "GITLAB:$gitlab”
"https://sonar/api/qualitygates/project_status?projectKey=${sonarProjectKe {
y}&branch=${PIPELINE_GIT_BRANCH}" >> status.json
"employee": {
cat status.json | jq '.projectStatus .status' > status.txt
sed 's/"//g' status.txt >> QG.txt "name": "sonoo",
echo "status=$(sed -n '1p' QG.txt)"
"ID": 56000,
if [ $(sed -n '1p' QG.txt) == 'ERROR' ]
then "Status": true
echo -e "*****$RED QUALITY GATE ERROR $NC*****" }
echo "Check https://sonar/dashboard?id=${sonarProjectKey}" }
cat status.json| jq '.employee’
exit 1FAILURE
cat status.json| jq '.employee.name'
else
echo "*****$GREEN QUALITY GATE OKAY $NC******"
echo "To validate check https://sonar/dashboard?id=${sonarProjectKey}"
fi
curl --request POST --header "PRIVATE-TOKEN: $TOKEN"
"https://gitlab/api/v4/projects/$PROJECT_ID/protected_branch
es?name=$MS_TARGET_BRANCH&push_access_level=40&merg
e_access_level=40" >> protectedbranches.txt
AUTOMATION 9 - To Check the process of a
Jar
(java –jar helloworld). Id runtime cpu mem RAM App -🡪 CPU RAM
MEM HARDWARE. (AWK, SED, GREP,PIPE)
• **hello=`ps -ef | grep -i helloworld- 20.1.2.3.jar | awk '{print $13}’`
• sed -i 's/mdreject.html/index.html/g' web.xml
• **sed -i 's/'"$version"'/'"$newversionCode"'/’ test.sh
• date1=`echo $date| sed 's/-//g’`
• **cat branch.json | jq '.branches[0].name' | tr -d '"' >> branch.txt
• ls -ltr | head -10
#Thank you for being the part of my family and let’s grow together