forked from docker-library/meta-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile.meta
More file actions
124 lines (116 loc) · 3.38 KB
/
Jenkinsfile.meta
File metadata and controls
124 lines (116 loc) · 3.38 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
properties([
disableConcurrentBuilds(),
disableResume(),
durabilityHint('PERFORMANCE_OPTIMIZED'),
pipelineTriggers([
githubPush(),
cron('@hourly'), // check periodically to bring in new image builds
]),
])
node {
stage('Checkout') {
// prevent meta from triggering itself
// If 'Include in polling' is enabled or 'Include in changelog' is enabled, then when polling occurs, the job will be started if changes are detected from this SCM source.
checkout(changelog: false, poll: false, scm: scmGit(
userRemoteConfigs: [[
url: 'git@github.com:docker-library/meta.git',
credentialsId: 'docker-library-bot',
name: 'origin',
]],
branches: [[name: '*/main']],
extensions: [
cloneOption(
noTags: true,
shallow: true,
depth: 1,
),
submodule(
parentCredentials: true,
recursiveSubmodules: true,
trackingSubmodules: true,
),
cleanBeforeCheckout(),
cleanAfterCheckout(),
[$class: 'RelativeTargetDirectory', relativeTargetDir: 'meta'],
],
))
checkout(scmGit(
userRemoteConfigs: [[
url: 'https://github.com/docker-library/official-images.git',
name: 'origin',
]],
branches: [[name: '*/master']],
extensions: [
cleanBeforeCheckout(),
cleanAfterCheckout(),
[$class: 'RelativeTargetDirectory', relativeTargetDir: 'meta/.doi'],
],
))
checkout(scmGit(
userRemoteConfigs: [[
url: 'https://github.com/docker-library/meta-scripts.git',
name: 'origin',
]],
branches: [[name: '*/main']],
extensions: [
cleanBeforeCheckout(),
cleanAfterCheckout(),
[$class: 'RelativeTargetDirectory', relativeTargetDir: 'meta/.scripts'],
],
))
sh '''
git -C meta config user.name 'Docker Library Bot'
git -C meta config user.email 'doi+docker-library-bot@docker.com'
'''
}
env.BASHBREW_LIBRARY = workspace + '/meta/.doi/library'
dir('meta') {
withCredentials([
// thanks to rate limits, we either have to "docker login" or look things up via our proxy
string(credentialsId: 'dockerhub-public-proxy', variable: 'DOCKERHUB_PUBLIC_PROXY'),
]) {
stage('Fetch') {
sh 'bashbrew --library .doi/library fetch --all'
}
stage('Sources') {
sh '''
# we only need to regenerate "sources.json" if ".doi" or ".scripts" have changed since we last generated it
needsBuild=
if [ ! -s commits.json ] || [ ! -s sources.json ]; then
needsBuild=1
fi
doi="$(git -C .doi log -1 --format='format:%H')"
scripts="$(git -C .scripts log -1 --format='format:%H')"
export doi scripts
jq -n '{ doi: env.doi, scripts: env.scripts }' | tee commits.json
if [ -z "$needsBuild" ] && ! git diff --exit-code commits.json; then
needsBuild=1
fi
if [ -n "$needsBuild" ]; then
# use previous run as cache
[ -s sources.json ] && cp sources.json sources-copy.json
.scripts/sources.sh --cache-file sources-copy.json --all > sources.json
# clean up temporary cache
rm -f sources-copy.json
fi
'''
}
stage('Builds') {
sh '.scripts/builds.sh --cache cache-builds.json sources.json > builds.json'
}
}
stage('Commit') {
sh '''
git add -A .
if ! git diff --staged --exit-code; then # commit fails if there's nothing to commit
git commit -m 'Update and regenerate'
fi
'''
}
sshagent(['docker-library-bot']) {
stage('Push') {
sh 'git push origin HEAD:main'
}
}
}
}