LXC specific steps

This commit is contained in:
2026-02-03 21:42:31 -05:00
parent 7277d00008
commit 0002afbb01

12
Jenkinsfile vendored
View File

@@ -99,8 +99,9 @@ pipeline {
steps { steps {
withCredentials([usernamePassword(credentialsId: 'opnsense-api', usernameVariable: 'OPNSENSE_KEY', passwordVariable: 'OPNSENSE_SECRET')]) { withCredentials([usernamePassword(credentialsId: 'opnsense-api', usernameVariable: 'OPNSENSE_KEY', passwordVariable: 'OPNSENSE_SECRET')]) {
script { script {
def templateHost = params.PROVISION_TYPE == 'VM' ? 'ubuntu24vm' : 'ubuntu24lxc' // LXC gets the correct hostname at clone time, VM uses template hostname
echo "Looking up DHCP lease for hostname: ${templateHost}" def lookupHost = params.PROVISION_TYPE == 'VM' ? 'ubuntu24vm' : params.HOSTNAME
echo "Looking up DHCP lease for hostname: ${lookupHost}"
// Wait for DHCP lease to appear // Wait for DHCP lease to appear
def vmIp = '' def vmIp = ''
@@ -116,7 +117,7 @@ pipeline {
python3 -c " python3 -c "
import sys, json import sys, json
data = json.load(sys.stdin) data = json.load(sys.stdin)
hostname = '${templateHost}' hostname = '${lookupHost}'
for row in data.get('rows', []): for row in data.get('rows', []):
if row.get('hostname') == hostname or row.get('client-hostname') == hostname: if row.get('hostname') == hostname or row.get('client-hostname') == hostname:
print(row.get('address', '')) print(row.get('address', ''))
@@ -127,7 +128,7 @@ for row in data.get('rows', []):
).trim() ).trim()
if (vmIp) { if (vmIp) {
echo "Found IP address: ${vmIp} for hostname: ${templateHost}" echo "Found IP address: ${vmIp} for hostname: ${lookupHost}"
return true return true
} }
echo "DHCP lease not found yet, retrying..." echo "DHCP lease not found yet, retrying..."
@@ -156,6 +157,9 @@ for row in data.get('rows', []):
} }
stage('Set Hostname') { stage('Set Hostname') {
when {
expression { params.PROVISION_TYPE == 'VM' }
}
steps { steps {
script { script {
def newHostname = params.HOSTNAME def newHostname = params.HOSTNAME