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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
| pipeline {
agent {
node { label 'linux' }
}
parameters {
choice(
name: 'choiceP',
choices: ['A', 'B'],
description: '<strong style="color:green;">A,B</strong>')
listGitBranches(
name: 'gitbranchP',
defaultValue: 'master',
credentialsId: 'gitlab-cred',
remoteURL: 'https://github.com/example.git',
description: '<strong style="color:green;">git分支选择,默认选择master分支</strong>',
type: 'PT_BRANCH_TAG',
tagFilter: '*',
branchFilter: 'refs/heads/(.*)',
quickFilterEnabled: true,
selectedValue: 'NONE',
sortMode: 'NONE')
}
environment {
srcDir = 'example'
timestamp = new Date().format('yyyyMMddHHmmss')
TIMESTAMP_D = sh(script: "TZ=UTC-8 date +'%Y%m%d'", returnStdout: true).trim()
}
stages {
stage('清理空间') {
steps {
cleanWs()
}
}
stage('克隆代码') {
steps {
checkout([
$class: 'GitSCM',
branches: [[name: "$gitbranchP"]],
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: "$srcDir"]],
userRemoteConfigs: [[credentialsId: 'gitlab-cred', url: 'https://github.com/example.git']]])
}
}
stage('并发构建') {
parallel {
stage('打包-A') {
steps {
script {
jobA = build(
job: 'job-group/a-job',
parameters: [
gitParameter(name: 'Branch', value: "${Branch}"),
string(name: 'ParamsB', value: "${ParamsB}")]
)
a_fullpath = jobA.buildVariables.fullpath
a_filename = jobA.buildVariables.filename
}
}
}
stage('打包-B') {
steps {
script {
jobB = build(
job: 'job-group/b-job',
parameters: [
gitParameter(name: 'Branch', value: "${Branch}"),
string(name: 'ParamsB', value: "${ParamsB}")]
)
b_fullpath = jobB.buildVariables.fullpath
b_filename = jobB.buildVariables.filename
}
}
}
}
}
}
}
|