-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-aliyun-repo-oss
60 lines (53 loc) · 1.63 KB
/
Jenkinsfile-aliyun-repo-oss
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
pipeline {
agent any
// 定义groovy脚本中使用的环境变量
// environment{
// // 将构建任务中的构建参数转换为环境变量
// IMAGE_TAG = sh(returnStdout: true,script: 'echo $image_tag').trim()
// ORIGIN_REPO = sh(returnStdout: true,script: 'echo $origin_repo').trim()
// REPO = sh(returnStdout: true,script: 'echo $repo').trim()
// BRANCH = sh(returnStdout: true,script: 'echo $branch').trim()
// }
// // 定义本次构建使用哪个标签的构建环境,本示例中为 “slave-pipeline”
// agent{
// node{
// label 'slave-pipeline'
// }
// }
stages {
stage('Git') {
steps {
git branch: params.branch, credentialsId: params.credId , url: params.GitUrl
}
}
stage('写入配置') {
steps {
sh '''
''' + params.WriteFile + '''
'''
}
}
stage('构建镜像') {
steps {
sh '''
docker build -t ${origin_repo}/${account}/${repo}:${image_tag} .
'''
}
}
stage('push镜像到阿里云') {
steps {
sh '''
docker login -u ${ali_account} -p ${ali_passwd} ${origin_repo}
docker push ${origin_repo}/${account}/${repo}:${image_tag}
'''
}
}
stage('清理镜像 ') {
steps {
sh '''
docker system prune -f
'''
}
}
}
}