big jenkinsifile update

This commit is contained in:
2025-10-12 16:48:52 -07:00
parent 40a8253229
commit 22b4ef4336
26 changed files with 148 additions and 54 deletions

View File

@ -42,9 +42,11 @@ pipeline {
steps {
// Generate the dynamic inventory file
sh """
jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | head -n 1)
jenkins_user=\$(echo ${env.BUILD_USER})
cd /var/jenkins_home/ansible
chmod +x /var/jenkins_home/ansible/inventory/generate_inventory.sh
/var/jenkins_home/ansible/inventory/generate_inventory.sh ${params.host_ip}
chmod +x /var/jenkins_home/ansible/inventory/inventory.sh
/var/jenkins_home/ansible/inventory/inventory.sh -s -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip}
"""
}
@ -77,7 +79,12 @@ pipeline {
post {
always {
// Remove dynamic Inventory file
sh "rm /var/jenkins_home/ansible/.inv/inventory-${params.host_ip}.yml"
sh """
hash=\$(echo -n "${params.host_ip}" | md5sum | cut -c 1-8)
inventory_file="/var/jenkins_home/ansible/.inv/inventory-\$hash.yml"
rm \$inventory_file
"""
}
}