Coder Social home page Coder Social logo

sf_12.1_jenkins's Introduction

Jenkins deployment pipeline

This is an exercise from sevf education as part of cource in SkillFactory.ru - DEVOPS

How To deploy Jenkins in Yandec Cloud

terraform apply

12.5

1. to launch docker with Wordpress via Jenkins Job (shell) on production Node

ssh [email protected] docker run -d -p 80:80 tutum/wordpress /run.sh

2. to launch docker with Wordpress via Jenkins Job (shell) on stating Node

ssh [email protected] docker run -d -p 80:80 tutum/wordpress /run.sh

3. to get Ping DOWN of Production and Stating Nodes via Jenkins Job (shell) every 5 min

ping -c 1 178.154.203.182
if [ $? -eq 1 ];  then
    echo "stating PING DOWN"  >> /home/jenkins/myping_sh.log
fi

ping -c 1 178.154.207.107
if [ $? -eq 1 ];  then
    echo "production PING DOWN" >> /home/jenkins/myping_sh.log
fi

4. to get UPtime from Production and Stating Nodes via Jenkins Job (shell) every 5 min

sh '''ssh [email protected] uptime >> /home/jenkins/statingUTime.log
ssh [email protected] uptime >> /home/jenkins/productionUTime.log'''

also via pipeline file (12.6)

pipeline {
    agent any
    stages {
        stage('Ping') {
            steps {
               sh '''ping -c 1 178.154.203.182
                    if [ $? -eq 1 ];  then
                    echo "stating PING DOWN"  >> /home/jenkins/myping_sh.log
                    fi

                    ping -c 1 178.154.207.107
                    if [ $? -eq 1 ];  then
                    echo "production PING DOWN" >> /home/jenkins/myping_sh.log
                    fi 
                '''
            }
        }
        stage('Uptime') {
            steps {
                sh '''ssh [email protected] uptime >> /home/jenkins/statingUTime.log
                ssh [email protected] uptime >> /home/jenkins/productionUTime.log'''
            }
        }
        stage('Docker') {
            steps {
                echo 'Hello World'
            }
        }
    }
}

5. to reboot Production or Stating or both Nodes via Jenkins Pipeline (12.6)

pipeline {
    agent any
    parameters{ choice(choices: ['All', 'production', 'stating'], description: 'which of server (s)',  name: 'ServerName') }    
    stages {
        stage('reboot Production') {
            agent { 
                label 'stating'
            }
            when {
                expression { 
                   return params.ServerName == 'production'
                }
            }
            steps {
                    sh """
                   reboot now
                    """
            }
        }
        stage('reboot staging') {
            when {
                expression { 
                   return params.ServerName == 'stating'
                }
            }
            steps {
                    sh """
                    ssh [email protected] reboot now
                    """
            }
        }
        stage('reboot all') {
            when {
                expression { 
                   return params.ServerName == 'stating'
                }
            }
            steps {
                    sh """
                    ssh [email protected] reboot now
                    ssh [email protected] reboot now
                    """
            }
        }
    }
}

sf_12.1_jenkins's People

Contributors

dkspace avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.