-
Notifications
You must be signed in to change notification settings - Fork 9
/
run_fresh_install_pipeline.groovy
62 lines (58 loc) · 3.35 KB
/
run_fresh_install_pipeline.groovy
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
import io.goharbor.*
// this is a pre-defined pipeline library which has implemented the common steps(e.g. health checking, test, result publishing, etd.)
// callers are responsible for the customized parts(e.g. installation) by implementing the abstract class "io.goharbor.FreshInstallPipelineExecutor"
def call(FreshInstallPipelineSettings settings) {
node(settings.node) {
catchError {
// set pipeline properties if defined
if (settings.properties){
properties(settings.properties())
}
cleanWs() // clean the workspace before running
checkout scm
HarborInstance instance
stage('Pre-Install') {
settings.executor.preInstall()
}
stage('Install') {
instance = settings.executor.install()
}
stage('Post-Install') {
settings.executor.postInstall()
}
stage('Health-Check') {
check_health(instance)
}
stage('Pre-Test') {
settings.executor.preTest()
}
stage('Test') {
// set the properties if not specifying
CaseSettings caseSettings = settings.caseSettings()
withCredentials([usernamePassword(credentialsId: "79e9fd98-cdf5-4f55-81fa-ecba01365534", usernameVariable: "DOCKER_HUB_USERNAME", passwordVariable: "DOCKER_HUB_PASSWORD"),
usernamePassword(credentialsId: "ecr-credential", usernameVariable: "ECR_ACCESS_ID", passwordVariable: "ECR_ACCESS_SECRET"),
usernamePassword(credentialsId: "gitlab-registry-credential", usernameVariable: "GITLAB_ACCESS_ID", passwordVariable: "GITLAB_ACCESS_SECRET"),
string(credentialsId: "gcr-credential", variable: "GCR_ACCESS_SECRET")]) {
caseSettings.dockerHubUsername = caseSettings.dockerHubUsername ? caseSettings.dockerHubUsername : env.DOCKER_HUB_USERNAME
caseSettings.dockerHubPassword = caseSettings.dockerHubPassword ? caseSettings.dockerHubPassword : env.DOCKER_HUB_PASSWORD
caseSettings.ecrAccessID = caseSettings.ecrAccessID ? caseSettings.ecrAccessID : env.ECR_ACCESS_ID
caseSettings.ecrAccessSecret = caseSettings.ecrAccessSecret ? caseSettings.ecrAccessSecret : env.ECR_ACCESS_SECRET
caseSettings.gitlabAccessID = caseSettings.gitlabAccessID ? caseSettings.gitlabAccessID : env.GITLAB_ACCESS_ID
caseSettings.gitlabAccessSecret = caseSettings.gitlabAccessSecret ? caseSettings.gitlabAccessSecret : env.GITLAB_ACCESS_SECRET
caseSettings.gcrAccessSecret = caseSettings.gcrAccessSecret ? caseSettings.gcrAccessSecret : env.GCR_ACCESS_SECRET
}
run_test_case(instance, caseSettings, "workdir")
}
stage('Post-Test') {
settings.executor.postTest()
}
}
// wrapped by catchError to make sure the result is always sent to slack channel
catchError {
publish_test_result("workdir/result")
}
withCredentials([string(credentialsId: "slack-token", variable: "SLACK_TOKEN")]) {
send_to_slack("#tkp-project-harbor-harbor_nightly_results", env.SLACK_TOKEN, "vmware")
}
}
}