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: '[email protected]: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
                   '''
            }
        }

    }



}

 

你可能感兴趣的:(Jenkinsfile构建docker镜像)