Singapore Flyer

Thursday, July 12, 2018

Jenkins Pipeline Parameter

Little background : I am running an inspec test for couple of servers. I accept server ip's as a jenkins parameter. Each IP the inspec test for the mysql profile should execute.

Parameter "IP_MYSQL" holds server ips

stage('Checking MySQL'){
    echo 'Inspec test for mysql'
    withCredentials([file(credentialsId: 'mysql-prod', variable: 'SSH_KEY')]) {
    sh '''
sudo git clone
cd mysql-baseline
    echo "${IP_MYSQL}" | sed -n 1'p' | tr ',' '\n' | while read IP; do
            sudo cp ../inspec.yml inspec.yml
            sudo sed -i -e "s/mysql-baseline/mysql-baseline-$IP/g" inspec.yml
            cd ..
            sudo inspec exec mysql-baseline -t ssh://clouduser@$IP -i $SSH_KEY --reporter junit:Report_$IP.xml || true
junit '*.xml'

No comments:

Post a Comment