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:yyy/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/yyy/official:$version .
                    sudo docker push 192.168.124.136/yyy/official:$version
                   '''
            }
        }

    }



}

 

posted @ 2019-06-26 15:33  Bigberg  阅读(3774)  评论(0编辑  收藏  举报