简单pipeline脚本
pipeline {agent anystages {stage('拉取代码') {steps {echo '拉取代码'}}stage('编译构建') {steps {echo '编译构建'}}stage('项目部署') {steps {echo '项目部署'}}}}

点击构建
可以看到每个步骤花费的时间
可以看到每个步骤日志
pipeline-ssh远程主机执行脚本
def getRemoteServer(ip){
      def remote = [:]
      remote.name = 'root'
      remote.host = ip
      remote.user = 'root'
      remote.password = 'xxxxxxxxxxx'
      remote.allowAnyHosts = true
    // withCredentials([usernamePassword(credentialsId: 'wukang', passwordVariable: 'password', usernameVariable: 'userName')]) {
    //     remote.user = "${userName}"
    //     remote.password = "${password}"
    // }
    return remote
}
pipeline {
    agent any
    stages {
        stage('连接跳板机') {
            steps {
                script{
                    remote = getRemoteServer("192.168.0.9")
                    sshCommand remote: remote, command: "ls -lrt"
                    sshCommand remote: remote, command: "for i in {1..5}; do echo -n \"Loop \$i \"; date ; sleep 1; done"
                }
            }
        }
        stage('拉取代码') {
            steps {
                echo '拉取代码'
            }
        }
        stage('编译构建') {
            steps {
                echo '编译构建'
            }
        }
        stage('项目部署') {
            steps {
                echo '项目部署'
                // sh 'ansible all -m ping'
            }
        }
    }
}
                    
