Skip to content

Latest commit

 

History

History
65 lines (54 loc) · 1.18 KB

zuo-docker-+-maven.md

File metadata and controls

65 lines (54 loc) · 1.18 KB

實作:Docker + Maven

使用 ubuntu_with_git_and_jdk 進行擴充:

docker run -i -t ubuntu_with_git_and_jdk /bin/bash

安裝 Maven:

apt-get install -y maven
mvn --version
exit

提交 ubuntu_with_git_and_jdk_maven:

docker commit 9821a4789b86 ubuntu_with_git_and_jdk_and_maven

修改 Jenkinsfile:

pipeline {
    agent {
        docker { image 'ubuntu_with_git_and_jdk_and_maven' }
    }
    stages {
        stage('Version') {
            steps {
                sh 'java -version'
                sh 'javac -version'
            }
        }
        stage('Clone') {
            steps {
                git url: 'http://localhost:8081/user/MyApp.git',
                  credentialsId: '023352b7-fbb9-4ee3-9c9c-5b5d734099cc'
            }
        }
        stage('Build') {
            steps {
                sh 'mvn clean test package'
            }
        }
        stage('Archive') {
            steps {
                archiveArtifacts artifacts: 'target/*.jar'
                junit 'target/surefire-reports/*.xml'
            }
        }
    }
}

使用 Triggers 觸發

triggers {
    cron('* * * * *')
}