-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat($module=convention/core): 🎉 完成 持续集成的 Jenkins 部署等相关功能
- 待改进: - 单元测试的集成 - ref #2
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,5 @@ ENTRYPOINT java \ | |
-Djava.security.egd=file:/dev/./urandom \ | ||
-jar /opt/app.jar | ||
|
||
# 使用端口 80 | ||
# 使用端口 8080 | ||
EXPOSE 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
pipeline { | ||
agent { | ||
docker { | ||
image 'maven:3.6-alpine' | ||
args '-u root -v /var/mvn/repos:/root/.m2' | ||
} | ||
|
||
} | ||
|
||
stages { | ||
stage('Prepare') { | ||
steps { | ||
echo "1 Prepare Stage" | ||
|
||
echo '1.0 检验 mvn 版本' | ||
sh 'mvn -v' | ||
|
||
echo '1.1 获取 项目 pom.xml 中的版本号' | ||
|
||
script { | ||
def __buildTag__ = sh "mvn -f pom.xml -q -Dexec.executable='echo' -Dexec.args='\${projects.version}' -N org.codehaus.mojo:exec-maven-plugin:1.3.1:exec" | ||
def buildTag = __buildTag__.trim() | ||
} | ||
|
||
echo buildTag | ||
input('构建版本号为【' + buildTag + '】, 确定吗?') | ||
} | ||
} | ||
stage('Test') { | ||
steps { | ||
echo "2.Test Stage" | ||
} | ||
} | ||
stage('Build') { | ||
steps { | ||
echo "3 Build Docker Image Stage" | ||
|
||
echo '3.0 使用 mvn 打包' | ||
sh 'mvn clean package -Dmaven.test.skip=true' | ||
|
||
echo '3.1 使用 mvn 构建 docker 镜像' | ||
sh 'mvn dockerfile:build -Dmaven.test.skip=true' | ||
} | ||
} | ||
stage('Push') { | ||
steps { | ||
echo "4.Push Docker Image Stage" | ||
withCredentials([usernamePassword(credentialsId: 'aliDockerRegistry', passwordVariable: 'dockerHubPassword', usernameVariable: 'dockerHubUser')]) { | ||
sh "docker login -u ${dockerHubUser} -p ${dockerHubPassword}" | ||
sh "docker push registry.cn-beijing.aliyuncs.com/o-w-o/api:${buildTag}" | ||
} | ||
} | ||
} | ||
stage('Deploy') { | ||
steps { | ||
echo "5. Deploy Stage" | ||
input "确认要部署线上环境吗?" | ||
} | ||
} | ||
} | ||
} |