1 Star 0 Fork 2

candyadmin/project-all

forked from 刘彪/ProjectAll 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Jenkinsfile 2.40 KB
一键复制 编辑 原始数据 按行查看 历史
LB59911 提交于 2022-02-09 11:00 . Jenkinsfile
pipeline {
agent {
node {
label 'maven'
}
}
stages {
stage('构建开始输出') {
agent none
steps {
echo '开始构建'
}
}
stage('拉取代码') {
agent none
steps {
echo '开始检出代码'
container('maven') {
git(url: 'https://gitee.com/liubiaowebcode/ImageTest.git', credentialsId: 'gitee', branch: 'master', changelog: true, poll: false)
sh 'ls -al'
}
}
}
stage('代码质量审核') {
agent none
steps {
container('maven') {
echo '开始审核代码'
waitForQualityGate 'true'
echo '代码审核完成'
}
}
}
stage('项目编译') {
agent none
steps {
echo '开始编译代码'
container('maven') {
sh 'ls -al'
sh ' mvn clean package -Dmaven.test.skip=true'
sh 'ls -al'
}
}
}
stage('构建镜像') {
agent none
steps {
echo '开始构建镜像'
container('maven') {
sh 'ls -al'
sh 'docker build -t image-test:latest -f Dockerfile .'
}
}
}
stage('确认是否推送') {
agent none
steps {
input(message: '是否推送镜像?', submitter: '')
}
}
stage('推送镜像') {
agent none
steps {
container('maven') {
withCredentials([usernamePassword(credentialsId : 'aliyun-hangzhou-image' ,usernameVariable : 'DOCKER_USERNAME' ,passwordVariable : 'DOCKER_PASSWORD' ,)]) {
sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker tag image-test:latest $REGISTRY/$DOCKERHUB_NAMESPACE/$STORE:image-test-v1-1-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$STORE:image-test-v1-1-$BUILD_NUMBER'
}
}
}
}
stage('构建结束输出') {
agent none
steps {
echo '构建结束'
}
}
}
environment {
DOCKER_CREDENTIAL_ID = 'dockerhub'
KUBECONFIG_CREDENTIAL_ID = 'kubeconfig'
REGISTRY = 'registry.cn-hangzhou.aliyuncs.com'
DOCKERHUB_NAMESPACE = 'liubiao_dev'
APP_NAME = 'devops-python-sample'
SONAR_CREDENTIAL_ID = 'sonar-token'
STORE = 'dev'
}
parameters {
string(name: 'BRANCH_NAME', defaultValue: 'master', description: '')
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/candyadmin/project-all.git
git@gitee.com:candyadmin/project-all.git
candyadmin
project-all
project-all
master

搜索帮助