-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
38 lines (38 loc) · 1.46 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
31
32
33
34
35
36
37
38
pipeline {
agent any
stages {
stage('检出') {
steps {
checkout([$class: 'GitSCM', branches: [[name: env.GIT_BUILD_REF]],userRemoteConfigs: [[url: env.GIT_REPO_URL, credentialsId: env.CREDENTIALS_ID]]])
}
}
stage('构建') {
agent {
label 'node-10'
}
steps {
echo '构建中...'
sh 'npm install'
sh 'cp webpack.config node_modules/react-scripts/config/webpack.config.js'
sh 'npm run build'
echo '构建完成.'
}
}
stage('打包镜像') {
steps {
echo '打包中...'
sh "docker build -t ${env.DOCKER_REPO_NAME}:${env.GIT_BUILD_REF} -t ${env.DOCKER_REPO_NAME}:latest ."
echo '打包完成'
}
}
stage('上传镜像到仓库') {
steps {
sh "docker login -u ${env.DOCKER_REPO_USER} -p ${env.DOCKER_REPO_PASSWORD} ${env.DOCKER_REPO_DOMAIN}"
sh "docker tag ${env.DOCKER_REPO_NAME}:${env.GIT_BUILD_REF} ${env.DOCKER_REPO_DOMAIN}/${env.DOCKER_REPO_NAMESPACE}/${env.DOCKER_REPO_NAME}:${env.GIT_BUILD_REF}"
sh "docker tag ${env.DOCKER_REPO_NAME}:${env.GIT_BUILD_REF} ${env.DOCKER_REPO_DOMAIN}/${env.DOCKER_REPO_NAMESPACE}/${env.DOCKER_REPO_NAME}:latest"
sh "docker push ${env.DOCKER_REPO_DOMAIN}/${env.DOCKER_REPO_NAMESPACE}/${env.DOCKER_REPO_NAME}:${env.GIT_BUILD_REF}"
sh "docker push ${env.DOCKER_REPO_DOMAIN}/${env.DOCKER_REPO_NAMESPACE}/${env.DOCKER_REPO_NAME}:latest"
}
}
}
}