我有一个jenkins工作,它将通过运行docker-compose文件在我的CentOS机器上进行部署。这是我的shell脚本的外观吗?
#!/bin/sh
# Post steps for deployment
# Navigate to deployment scripts
cd /deployment/scripts/v1.0.784
#Execute the uninstall script
./dit_undeploy_all.sh
set +e
#Remove all docker images and containers
docker container rm $(docker ps -a -q) -f
docker rmi $(docker images -a -q)
docker volume rm $(docker volume ls -q)
set -e
#Remove and clear out the folder structure
rm -rf *.*
#Gets all the latest files from Artifactory by reading from teh input file
wget -B https://artifactory.gue.com -i /deployment/scripts/inputFile.txt
# Gives rea/write access
chmod +x *.*
# Execute docker compose file to get all the latest containers
./dit_deploy_all.sh
#Add wait time for the services to be up and running
sleep 60s #Wait 15 sec
# Need to update the URL
./dit_create_policies.sh
#Verify URL Status Code of 200
cd /deployment/scripts
sleep 60s #Wait time 60s
./verifyHttpCode
脚本./verifyHttpCode执行以下操作:
#!/bin/bash
while read LINE; do
curl -o /dev/null --silent --head --write-out '%{http_code}' "$LINE"
echo " $LINE"
done < url-list.txt
所以基本上在部署之后它将验证http状态代码...我在Jenkins中可以使用shell脚本中的testNG相当于验证http状态代码并生成报告吗?
答案 0 :(得分:0)
您是否尝试过此插件:Audit2DB
https://wiki.jenkins.io/display/JENKINS/Audit+To+Database+Plugin
它会将所有必需的作业详细信息记录到数据库中。如果要创建报告,它将从DB获取它。 因此,在这种情况下,您需要在脚本失败时使作业失败(非零退出)。您还可以在完成作业时将$ http_code设置为env变量,并将其记录到数据库中。