-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfile
30 lines (30 loc) · 1.13 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
pipeline {
agent any
environment {
GIT_CREDENTIALS_ID = 'git-ssh-credential' // Jenkins中配置的git秘钥ID
MAVEN_INSTALLATION_NAME = 'maven' // Jenkins中配置的Maven installation名称
GIT_URL = "${gitlabSourceRepoURL}" // git url,demo使用了gitlab webhook注入的环境变量,使用其他git(github/bitbucket等)时请修改为对应的变量
GIT_BRANCH = "${gitlabBranch}" // git branch,demo使用了gitlab webhook注入的环境变量,使用其他git(github/bitbucket等)时请修改为对应的变量
}
stages {
stage('Checkout') {
steps {
git credentialsId: env.GIT_CREDENTIALS_ID, poll: false, url: env.GIT_URL, branch: env.GIT_BRANCH
}
}
stage('Test') {
steps {
withMaven(maven: env.MAVEN_INSTALLATION_NAME) {
sh "mvn clean test"
}
}
}
stage('Build & Archive') {
steps {
withMaven(maven: env.MAVEN_INSTALLATION_NAME) {
sh "mvn package"
}
}
}
}
}