I have written the following code to execute the ansible playbook, but got the following error:
stage('Artifacts') {
when {
expression {
params.version =~ /SNAPSHOT/
}
}
steps {
dir('feature') {
checkout resolveScm(source: [$class: 'GitSCMSource', credentialsId: 'svcPsdGit-ssh', id: '_', remote: 'ssh://git@psdgit.:7999/tt040/it-infra.git', traits: [gitBranchDiscovery()]], targets: [params.main_branch])
sh '''
echo "`pwd`"
env | sort
cd ansible/playbooks
ansible-playbook --extra-vars="artifactory_folder=gssd-dev-snapshots-local" playbooks/deploy.yml
'''
}
}
}
Error:
cd ansible/playbooks
+ ansible-playbook --extra-vars=artifactory_folder=gssd-dev-snapshots-local playbooks/deploy.yml
/home/centos/workspace/MY/Snapshot_deployment/feature@tmp/durable-1c0f5688/script.sh: line 5: ansible-playbook: command not found
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
Can you please help me out?