93 lines
2.7 KiB
Plaintext
93 lines
2.7 KiB
Plaintext
|
pipeline {
|
||
|
//agent any
|
||
|
agent {
|
||
|
docker {
|
||
|
image 'jtom38/ansible:2.10.3'
|
||
|
args '-u 0:0'
|
||
|
}
|
||
|
}
|
||
|
triggers {
|
||
|
cron('H 2 * * 7')
|
||
|
}
|
||
|
environment {
|
||
|
GIT_BRANCH='dev'
|
||
|
GIT_URL='https://github.com/jtom38/ansible.git'
|
||
|
ANSIBLE_VAULT_FILE='./.ansible_vault'
|
||
|
|
||
|
// This will allow us to not pass
|
||
|
ANSIBLE_HOST_KEY_CHECKING='False'
|
||
|
|
||
|
DISCORD_HOOK=credentials('discord-mm-hook')
|
||
|
DISCORD_JOB_NAME='ansible-job-common'
|
||
|
DISCORD_FOOTER='Jenkins Automation'
|
||
|
}
|
||
|
stages {
|
||
|
stage('Checkout-Code') {
|
||
|
steps {
|
||
|
sh ''' #!/bin/bash
|
||
|
#echo "Cleaning up old builds"
|
||
|
#rm ./gitAnsible -f -r
|
||
|
|
||
|
git clone ${GIT_URL} gitAnsible || echo "skip checkout"
|
||
|
cd ./gitAnsible
|
||
|
git checkout ${GIT_BRANCH}
|
||
|
git pull
|
||
|
'''
|
||
|
}
|
||
|
}
|
||
|
stage('Set-Secret') {
|
||
|
steps {
|
||
|
withCredentials([file(credentialsId: 'ansible-vault-file', variable: 'FILE')]) {
|
||
|
sh '''#!/bin/bash
|
||
|
echo "Set Vault File"
|
||
|
cp $FILE ./gitAnsible/.ansible_vault
|
||
|
'''
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
stage('Get-Galaxy-Requirements'){
|
||
|
steps {
|
||
|
sh '''#!/bin/bash
|
||
|
cd ./gitAnsible
|
||
|
ansible-galaxy install -r requirements.yml
|
||
|
'''
|
||
|
}
|
||
|
}
|
||
|
stage('Run-Linux-Common') {
|
||
|
steps {
|
||
|
sh '''#!/bin/bash
|
||
|
cd ./gitAnsible
|
||
|
ansible-playbook ./playbook/linux/common.yml -i ./inventory
|
||
|
'''
|
||
|
}
|
||
|
}
|
||
|
stage('Run-Docker-Common') {
|
||
|
steps {
|
||
|
sh '''#!/bin/bash
|
||
|
cd ./gitAnsible
|
||
|
ansible-playbook ./playbook/docker/common.yml -i ./inventory
|
||
|
'''
|
||
|
}
|
||
|
}
|
||
|
stage('Run-MediaServer-Common') {
|
||
|
steps {
|
||
|
sh '''#!/bin/bash
|
||
|
cd ./gitAnsible
|
||
|
ansible-playbook ./playbook/docker/mediaserver/common.yml -i ./inventory
|
||
|
'''
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
post {
|
||
|
always {
|
||
|
sh 'rm -f ./gitAnsible/.ansible_vault'
|
||
|
discordSend description: "Job Status is "+currentBuild.currentResult+"!", footer: env.DISCORD_FOOTER, link: env.BUILD_URL, result: currentBuild.currentResult, title: env.DISCORD_JOB_NAME, webhookURL: env.DISCORD_HOOK
|
||
|
}
|
||
|
/*
|
||
|
success {}
|
||
|
failure {}
|
||
|
*/
|
||
|
}
|
||
|
}
|