forked from theonedev/onedev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.onedev-buildspec
185 lines (184 loc) · 9.24 KB
/
.onedev-buildspec
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?xml version="1.0" encoding="UTF-8"?>
<io.onedev.server.buildspec.BuildSpec revision="1">
<jobs>
<io.onedev.server.buildspec.job.Job>
<name>CI</name>
<paramSpecs/>
<image>1dev/build-environment:1.1</image>
<commands>
<string>set -e</string>
<string>echo "Detecting project version (may require some time while downloading maven dependencies)..."</string>
<string>buildVersion=$(mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout)</string>
<string>echo "##onedev[SetBuildVersion '$buildVersion']"</string>
<string>mvn test</string>
</commands>
<retrieveSource>true</retrieveSource>
<cloneDepth>1</cloneDepth>
<submoduleCredentials/>
<jobDependencies/>
<projectDependencies/>
<services/>
<reports/>
<triggers>
<io.onedev.server.buildspec.job.trigger.BranchUpdateTrigger>
<params/>
<branches>master</branches>
</io.onedev.server.buildspec.job.trigger.BranchUpdateTrigger>
<io.onedev.server.buildspec.job.trigger.PullRequestTrigger>
<params/>
</io.onedev.server.buildspec.job.trigger.PullRequestTrigger>
</triggers>
<caches>
<io.onedev.server.buildspec.job.CacheSpec>
<key>maven-cache</key>
<path>/root/.m2/repository</path>
</io.onedev.server.buildspec.job.CacheSpec>
</caches>
<cpuRequirement>250m</cpuRequirement>
<memoryRequirement>128m</memoryRequirement>
<timeout>3600</timeout>
<postBuildActions/>
<retryCondition>never</retryCondition>
<maxRetries>3</maxRetries>
<retryDelay>30</retryDelay>
</io.onedev.server.buildspec.job.Job>
<io.onedev.server.buildspec.job.Job>
<name>Release</name>
<paramSpecs/>
<image>1dev/build-environment:1.1</image>
<commands>
<string>set -e</string>
<string>docker login -u robinshen -p @secrets:dockerhub-password@</string>
<string></string>
<string>echo "Detecting project version (may require some time while downloading maven dependencies)..."</string>
<string>buildVersion=$(mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout)</string>
<string>echo "##onedev[SetBuildVersion '$buildVersion']"</string>
<string></string>
<string># Skip test as we've already tested in CI build</string>
<string>mvn -Dmaven.test.skip=true -Dmaven.deploy.password=@secrets:maven-deploy-password@ deploy</string>
<string></string>
<string>curl -u onedev:@secrets:maven-deploy-password@ -f -d \@/root/.m2/archetype-catalog.xml -X PUT "https://artifact.onedev.io/artifactory/onedev/archetype-catalog.xml"</string>
<string></string>
<string>cp -r server-product/docker docker</string>
<string>cp server-product/target/onedev-${buildVersion}.zip .</string>
<string>unzip onedev-${buildVersion}.zip -d docker</string>
<string>mv docker/onedev-${buildVersion} docker/app</string>
<string>cp server-product/target/sandbox/site/lib/mysql* server-product/target/sandbox/site/lib/postgresql* docker/app/site/lib</string>
<string></string>
<string>docker build -t 1dev/server:${buildVersion} docker</string>
<string>docker push 1dev/server:${buildVersion}</string>
<string>docker tag 1dev/server:${buildVersion} 1dev/server:latest</string>
<string>docker push 1dev/server:latest</string>
<string></string>
<string>cp -r server-product/k8s k8s-resources</string>
<string>find k8s-resources -name "*.yaml" | xargs sed -i -e "s/\\${buildVersion}/${buildVersion}/g"</string>
<string>zip -r k8s-resources.zip k8s-resources</string>
<string></string>
<string>cat << EOF > run-as-docker.sh</string>
<string>docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v \\$(which docker):/usr/bin/docker -v \\$(pwd)/onedev:/opt/onedev -p 6610:6610 1dev/server:${buildVersion}</string>
<string>EOF</string>
</commands>
<retrieveSource>true</retrieveSource>
<cloneDepth>1</cloneDepth>
<submoduleCredentials/>
<jobDependencies>
<io.onedev.server.buildspec.job.JobDependency>
<jobName>CI</jobName>
<requireSuccessful>true</requireSuccessful>
<jobParams/>
</io.onedev.server.buildspec.job.JobDependency>
</jobDependencies>
<projectDependencies/>
<services/>
<artifacts>*.zip *.sh</artifacts>
<reports/>
<triggers/>
<caches>
<io.onedev.server.buildspec.job.CacheSpec>
<key>maven-cache</key>
<path>/root/.m2/repository</path>
</io.onedev.server.buildspec.job.CacheSpec>
</caches>
<cpuRequirement>250m</cpuRequirement>
<memoryRequirement>128m</memoryRequirement>
<timeout>3600</timeout>
<postBuildActions>
<io.onedev.server.buildspec.job.action.CreateTagAction>
<condition>successful</condition>
<tagName>v@build_version@</tagName>
</io.onedev.server.buildspec.job.action.CreateTagAction>
<io.onedev.server.buildspec.job.action.CloseMilestoneAction>
<condition>successful</condition>
<milestoneName>@build_version@</milestoneName>
</io.onedev.server.buildspec.job.action.CloseMilestoneAction>
</postBuildActions>
<retryCondition>never</retryCondition>
<maxRetries>3</maxRetries>
<retryDelay>30</retryDelay>
<defaultFixedIssuesFilter>"State" is "Closed" order by "Type" asc and "Priority" desc</defaultFixedIssuesFilter>
</io.onedev.server.buildspec.job.Job>
<io.onedev.server.buildspec.job.Job>
<name>Sync Master (GitHub)</name>
<paramSpecs/>
<image>alpine/git:1.0.7</image>
<commands>
<string>git push -f https://robinshine:@secrets:github-password@\@github.com/theonedev/server HEAD:master</string>
</commands>
<retrieveSource>true</retrieveSource>
<submoduleCredentials/>
<jobDependencies/>
<projectDependencies/>
<services/>
<reports/>
<triggers>
<io.onedev.server.buildspec.job.trigger.BranchUpdateTrigger>
<params/>
<branches>master</branches>
</io.onedev.server.buildspec.job.trigger.BranchUpdateTrigger>
</triggers>
<caches/>
<cpuRequirement>250m</cpuRequirement>
<memoryRequirement>128m</memoryRequirement>
<timeout>3600</timeout>
<postBuildActions/>
<retryCondition>never</retryCondition>
<maxRetries>3</maxRetries>
<retryDelay>30</retryDelay>
</io.onedev.server.buildspec.job.Job>
<io.onedev.server.buildspec.job.Job>
<name>Sync Tags (GitHub)</name>
<paramSpecs/>
<image>alpine/git:1.0.7</image>
<commands>
<string>set -e</string>
<string>git fetch --tags https://robin:@secrets:onedev-password@\@code.onedev.io/projects/onedev-server</string>
<string>git push -f --tags https://robinshine:@secrets:github-password@\@github.com/theonedev/onedev</string>
</commands>
<retrieveSource>true</retrieveSource>
<submoduleCredentials/>
<jobDependencies/>
<projectDependencies/>
<services/>
<reports/>
<triggers>
<io.onedev.server.buildspec.job.trigger.TagCreateTrigger>
<params/>
</io.onedev.server.buildspec.job.trigger.TagCreateTrigger>
</triggers>
<caches>
<io.onedev.server.buildspec.job.CacheSpec>
<key>maven-cache</key>
<path>/root/.m2/repository</path>
</io.onedev.server.buildspec.job.CacheSpec>
</caches>
<cpuRequirement>250m</cpuRequirement>
<memoryRequirement>128m</memoryRequirement>
<timeout>3600</timeout>
<postBuildActions/>
<retryCondition>never</retryCondition>
<maxRetries>3</maxRetries>
<retryDelay>30</retryDelay>
</io.onedev.server.buildspec.job.Job>
</jobs>
<properties/>
</io.onedev.server.buildspec.BuildSpec>