mirror of
https://github.com/Dannecron/netology-devops.git
synced 2025-12-26 07:42:36 +03:00
homework 9.4: complete
This commit is contained in:
17
src/homework/09-ci/9.4/pipeline/Jenkinsfile
vendored
Normal file
17
src/homework/09-ci/9.4/pipeline/Jenkinsfile
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
node("linux"){
|
||||
stage("Git checkout"){
|
||||
git credentialsId: '5ac0095d-0185-431b-94da-09a0ad9b0e2c', url: 'git@github.com:aragastmatb/example-playbook.git'
|
||||
}
|
||||
stage("Sample define secret_check"){
|
||||
secret_check=true
|
||||
}
|
||||
stage("Run playbook"){
|
||||
if (secret_check){
|
||||
sh 'ansible-playbook site.yml -i inventory/prod.yml'
|
||||
}
|
||||
else{
|
||||
echo 'need more action'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
20
src/homework/09-ci/9.4/pipeline/JenkinsfileMultibranch
Normal file
20
src/homework/09-ci/9.4/pipeline/JenkinsfileMultibranch
Normal file
@@ -0,0 +1,20 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('checkout') {
|
||||
steps {
|
||||
echo 'Hello World'
|
||||
git credentialsId: '6659caf8-95a2-4201-b6e0-bfe65e71836d',
|
||||
url: 'git@github.com:Dannecron/netology-devops-ansible-vector.git',
|
||||
branch: 'main'
|
||||
}
|
||||
}
|
||||
stage('test') {
|
||||
steps {
|
||||
echo 'Run molecule test'
|
||||
sh 'molecule test'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
20
src/homework/09-ci/9.4/pipeline/JenkinsfileScripted
Normal file
20
src/homework/09-ci/9.4/pipeline/JenkinsfileScripted
Normal file
@@ -0,0 +1,20 @@
|
||||
def base_command = 'ansible-playbook site.yml -i inventory/prod.yml'
|
||||
|
||||
node("agent"){
|
||||
parameters {
|
||||
string(name: 'prod_run', defaultValue: 'False', description: 'Run without --check and --diff')
|
||||
}
|
||||
|
||||
stage("Git checkout"){
|
||||
git credentialsId: '6659caf8-95a2-4201-b6e0-bfe65e71836d',
|
||||
url: 'git@github.com:aragastmatb/example-playbook.git'
|
||||
}
|
||||
|
||||
stage("Run playbook") {
|
||||
if (params.prod_run == 'True') {
|
||||
sh(base_command)
|
||||
} else {
|
||||
sh("$base_command --check --diff")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user