其他分享
首页 > 其他分享> > Jenkinsfile构建docker镜像

Jenkinsfile构建docker镜像

作者:互联网

pipeline {
    agent any

    stages {
        stage('preparation') {
            steps {
                echo "workspace: ${WORKSPACE}"
                echo "build_tag: ${BUILD_TAG}"
                echo "node_name: ${NODE_NAME}"
                echo "version: ${version}"
            }
        }

        stage('git-official') {
            steps {
                echo "get code from git"
                dir(path: "./official") {
                    git(
                        branch: "master",
                        credentialsId: '4c54756d-241f-4825-be18-80f281081370',
                        url: 'git@192.168.124.189:jiayikou/official.git',
                        changelog: true
                        )
                }
            }
        }


        stage('docker-build') {
            steps {
                sh '''
                    cd jenkins/official/$version
                    cp -r ${WORKSPACE}/official/index.html .
                    cp -r ${WORKSPACE}/official/static .
                    sudo docker build -t 192.168.124.136/jiayikou/official:$version .
                    sudo docker push 192.168.124.136/jiayikou/official:$version
                   '''
            }
        }

    }



}

 

标签:jiayikou,git,official,echo,version,镜像,docker,Jenkinsfile
来源: https://www.cnblogs.com/bigberg/p/11090172.html