6.Jenkins主从搭建以及使用

目的

完成Jenkins主从搭建,并且通过自由风格、pipeline、node方式的应用Demo

Jenkins主从搭建

代理

Manage Jenkins->Configure Global Security

image-20220421111341967

新建Jenkins节点

Manage Jenkins->Manage Nodes and Clouds->新建节点

image-20220421111648499

部署Agent.jar

image-20220421112111164

执行命令后效果

image-20220421112310752

从节点测试

Freestyle project

image-20220421113312977

pipeline-pipeline

pipeline {
    agent {
	    //指定从节点
        label "slave"
    }

    stages {
        stage('Hello') {
            steps {
                checkout([$class: 'GitSCM', branches: [[name: '*/master2']], extensions: [], userRemoteConfigs: [[credentialsId: '538da12e-f04b-41f2-adc3-7e1728a5bd1e', url: 'https://gitee.com/RollBack2010/jekins-study.git']]])
            }
        }
    }
}

pipeline-node

node("slave") {
    stage('Preparation') { // for display purposes
        checkout([$class: 'GitSCM', branches: [[name: '*/master2']], extensions: [], userRemoteConfigs: [[credentialsId: '538da12e-f04b-41f2-adc3-7e1728a5bd1e', url: 'https://gitee.com/RollBack2010/jekins-study.git']]])
    }
}
posted @ 2022-04-26 16:50  RollBack2010  阅读(73)  评论(0编辑  收藏  举报