Jenkins : Pipeline Coding : Declarative

 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Using Multiple agents in s Jenkins Pipeline : https://www.youtube.com/watch?v=a25n3NeXD2o

 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


https://www.jenkins.io/doc/pipeline/tour/running-multiple-steps/


On Linux, BSD, and Mac OS (Unix-like) systems, the sh step is used to execute a shell command in a Pipeline.

Jenkinsfile (Declarative Pipeline)
pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                sh 'echo "Hello World"'
                sh '''
                    echo "Multiline shell steps works too"
                    ls -lah
                '''
            }
        }
    }
}

Executing an Ansible Job using 

pipeline {
    agent any
    stages {
        stage ("SCM checkout") {
            steps {
                git "https://github.com/muzakkirsaifi123/Blog1.git"
                
            }
        }
        stage(" execute Ansible") {
           steps {
                ansiblePlaybook credentialsId: 'private-key', disableHostKeyChecking: true, installation: 'Ansible', inventory: 'dev.inv', playbook: 'apache.yml'
            }    
        }    
    }

Tell Jenkins to run a specific project on a particular slave node

How to use multiple agents in a single pipeline? 



Comments

Popular posts from this blog

Jenkins file | declarative pipeline scripting

Jenkins : Webhooks

JENKINS -- My Work -Project - DNS