This repository has been archived by the owner on Dec 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
release.Jenkinsfile
159 lines (154 loc) · 6.28 KB
/
release.Jenkinsfile
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
pipeline {
agent any
tools {
go 'Go 1.18'
}
environment {
RELEASE_TYPE = 'release'
RC_NUMBER = "1"
BUMP_COMPONENT = "${params.BUMP_COMPONENT}"
GIT_BRANCH = getCurrentBranchName()
GIT_CREDENTIAL_ID = 'wf-jenkins-github'
TOKEN = credentials('GITHUB_TOKEN')
}
stages {
stage("Setup tools") {
steps {
withEnv(["PATH+EXTRA=${HOME}/go/bin"]) {
sh './hack/jenkins/install_docker_buildx.sh'
sh 'make semver-cli'
}
}
}
stage("Create Bump Version Branch") {
steps {
withEnv(["PATH+EXTRA=${HOME}/go/bin"]){
sh 'git config --global user.email "svc.wf-jenkins@vmware.com"'
sh 'git config --global user.name "svc.wf-jenkins"'
sh 'git remote set-url origin https://${TOKEN}@github.com/wavefronthq/wavefront-collector-for-kubernetes.git'
sh './hack/jenkins/create-bump-version-branch.sh "${BUMP_COMPONENT}"'
}
}
}
stage("Publish RC Release") {
environment {
HARBOR_CREDS = credentials("projects-registry-vmware-tanzu_observability-robot")
PREFIX = 'projects.registry.vmware.com/tanzu_observability'
DOCKER_IMAGE = 'kubernetes-collector'
RELEASE_TYPE = 'rc'
}
steps {
sh 'echo $HARBOR_CREDS_PSW | docker login $PREFIX -u $HARBOR_CREDS_USR --password-stdin'
sh 'HARBOR_CREDS_USR=$(echo $HARBOR_CREDS_USR | sed \'s/\\$/\\$\\$/\') make publish'
}
}
// deploy to GKE and run manual tests
// now we have confidence in the validity of our RC release
stage("Deploy and Test") {
environment {
GCP_CREDS = credentials("GCP_CREDS")
GKE_CLUSTER_NAME = "k8po-jenkins-ci-zone-a"
GCP_ZONE="a"
WAVEFRONT_TOKEN = credentials("WAVEFRONT_TOKEN_NIMBA")
WF_CLUSTER = 'nimba'
RELEASE_TYPE = 'rc'
}
steps {
script {
env.VERSION = readFile('./release/VERSION').trim()
env.CURRENT_VERSION = "${env.VERSION}-rc-${env.RC_NUMBER}"
env.CONFIG_CLUSTER_NAME = "jenkins-${env.CURRENT_VERSION}-test"
}
withCredentials([string(credentialsId: 'nimba-wavefront-token', variable: 'WAVEFRONT_TOKEN')]) {
withEnv(["PATH+GCLOUD=${HOME}/google-cloud-sdk/bin"]) {
lock("integration-test-gke") {
sh './hack/jenkins/setup-for-integration-test.sh -k gke'
sh 'make gke-connect-to-cluster'
sh 'make clean-cluster'
sh './hack/test/deploy/deploy-local-linux.sh'
sh './hack/test/test-wavefront-metrics.sh -c ${WF_CLUSTER} -t ${WAVEFRONT_TOKEN} -n ${CONFIG_CLUSTER_NAME} -v ${VERSION}'
sh 'make clean-cluster'
}
}
}
}
}
stage("Publish GA Harbor Image") {
environment {
HARBOR_CREDS = credentials("projects-registry-vmware-tanzu_observability-robot")
RELEASE_TYPE = 'release'
PREFIX = 'projects.registry.vmware.com/tanzu_observability'
DOCKER_IMAGE = 'kubernetes-collector'
}
steps {
sh 'echo $HARBOR_CREDS_PSW | docker login $PREFIX -u $HARBOR_CREDS_USR --password-stdin'
sh 'HARBOR_CREDS_USR=$(echo $HARBOR_CREDS_USR | sed \'s/\\$/\\$\\$/\') make publish'
}
}
stage("Publish GA Docker Hub") {
environment {
DOCKERHUB_CREDS=credentials('Dockerhub_svcwfjenkins')
RELEASE_TYPE = 'release'
PREFIX = 'wavefronthq'
DOCKER_IMAGE = 'wavefront-kubernetes-collector'
}
steps {
sh 'echo $DOCKERHUB_CREDS_PSW | docker login -u $DOCKERHUB_CREDS_USR --password-stdin'
sh 'make publish'
}
}
stage("Push Openshift Image to RedHat Connect") {
environment {
REDHAT_CREDS=credentials('redhat-connect-wf-collector-creds')
REDHAT_OSPID=credentials("redhat-connect-ospid-wf-collector")
REDHAT_API_KEY=credentials("redhat-connect-api-key")
REDHAT_PROJECT_ID=credentials("redhat-connect-collector-project-id")
OPENSHIFT_CREDS_PSW=credentials('OPENSHIFT_CREDS_PSW')
OPENSHIFT_VM=credentials('OPENSHIFT_VM')
GIT_BUMP_BRANCH_NAME = "${sh(script:'git name-rev --name-only HEAD', returnStdout: true).trim()}"
}
steps {
script {
env.PREFIX = "quay.io/redhat-isv-containers/${env.REDHAT_PROJECT_ID}"
}
sh """
sshpass -p "${OPENSHIFT_CREDS_PSW}" ssh -o StrictHostKeyChecking=no root@${OPENSHIFT_VM} "bash -s" < hack/jenkins/release-openshift-container.sh \
${PREFIX} \
${REDHAT_CREDS_USR} \
${REDHAT_CREDS_PSW} \
${REDHAT_API_KEY} \
${REDHAT_PROJECT_ID} \
${GIT_BUMP_BRANCH_NAME} \
${RC_NUMBER}
"""
}
}
stage("Create and Merge Bump Version Pull Request") {
steps {
sh './hack/jenkins/create-and-merge-pull-request.sh'
}
}
stage("Github Release") {
environment {
GITHUB_CREDS_PSW = credentials("GITHUB_TOKEN")
}
steps {
sh './hack/jenkins/generate_github_release.sh'
}
}
}
post {
regression {
slackSend (channel: '#tobs-k8po-team', color: '#FF0000', message: "RELEASE BUILD FAILED: <${env.BUILD_URL}|${env.JOB_NAME} [${env.BUILD_NUMBER}]>")
}
success {
script {
BUILD_VERSION = readFile('./release/VERSION').trim()
slackSend (channel: '#tobs-k8s-assist', color: '#008000', message: "Success!! `wavefront-collector-for-kubernetes:v${BUILD_VERSION}` released!")
}
}
}
}
def getCurrentBranchName() {
return env.BRANCH_NAME.split("/")[1]
}