[DO-1519] add messenger master web host and some refactoring (!79)

Co-authored-by: Rustam Tagaev <rustam.tagaev@avroid.tech>
Reviewed-on: https://git.avroid.tech/DevOps/jenkins-pipelines/pulls/79
Reviewed-by: Denis Patrakeev <denis.patrakeev@avroid.team>
This commit is contained in:
Rustam Tagaev
2025-02-11 13:39:38 +03:00
parent 8b5251920c
commit 39dd4cf5a0
4 changed files with 243 additions and 44 deletions

View File

@@ -39,13 +39,13 @@ import java.util.regex.Pattern
def createGetHttpClient(String url, String jenkinsCreds) {
def jenkinsCredentials = CredentialsProvider.lookupCredentials(StandardUsernamePasswordCredentials.class)
def credentials = jenkinsCredentials.findResult { it.id == jenkinsCreds ? it : null }
String auth = credentials.username + ":" + credentials.password;
String encodedAuth = Base64.getEncoder().encodeToString(auth.getBytes("utf-8"));
String authHeaderValue = "Basic " + encodedAuth;
String auth = 'robot' + '\$' + 'ci' + ":" + credentials.password
String encodedAuth = Base64.getEncoder().encodeToString(auth.getBytes("utf-8"))
String authHeaderValue = "Basic " + encodedAuth
def httpClient = new URL(url).openConnection() as HttpURLConnection
httpClient.setRequestMethod('GET');
httpClient.setRequestProperty("Authorization", authHeaderValue);
httpClient.setRequestProperty("Accept", "application/json");
httpClient.setRequestMethod('GET')
httpClient.setRequestProperty("Authorization", authHeaderValue)
httpClient.setRequestProperty("Accept", "application/json")
return httpClient
}
@@ -82,22 +82,6 @@ String helmChart = 'msg-messenger-core-api'
String helmRepoPath = "avroid/${helmChart}"
String helmRepo = "${env.JENKINS_NEXUS_URL}/repository/avroid-charts"
Map configuration = [
vaultUrl: env.JENKINS_VAULT_URL,
vaultCredentialId: "${JENKINS_VAULT_TOKEN}",
engineVersion: 2
]
List dockerCreds = [
[path: 'team-devops/services/ci-cd/Jenkins/jenkins.avroid.tech', engineVersion: 2,
secretValues:
[
[vaultKey: 'k8s_jenkins_deploy_token'],
]
]
]
Git git = new Git(this, env.JENKINS_GIT_CREDENTIALS_SSH)
PodTemplates slaveTemplates = new PodTemplates(this, env.JENKINS_DOCKER_REGISTRY,
["${env.JENKINS_K8S_HARBOR_SECRET}"],
@@ -107,22 +91,20 @@ slaveTemplates.jnlp {
slaveTemplates.helm {
try {
node(POD_LABEL){
withVault([configuration: configuration, vaultSecrets: dockerCreds]) {
stage('get repo with values'){
gitVars = git.clone([urlRepo: "${env.JENKINS_GIT_REPOSITORY_SSH_URL}/${repoPath}",
branch: branch])
}
container('helm'){
stage('deploy'){
echo "Deploying version ${env.APP_VERSION} to ${namespace} namespace"
sh """#!/bin/sh
helm repo add avroid ${helmRepo}
helm -n ${namespace} upgrade -f ${valuesPath} \
--set image.tag=${env.APP_VERSION} \
--install ${k8sAppName} ${helmRepoPath} \
--wait
"""
}
stage('get repo with values'){
gitVars = git.clone([urlRepo: "${env.JENKINS_GIT_REPOSITORY_SSH_URL}/${repoPath}",
branch: branch])
}
container('helm'){
stage('deploy'){
echo "Deploying version ${env.APP_VERSION} to ${namespace} namespace"
sh """#!/bin/sh
helm repo add avroid ${helmRepo}
helm -n ${namespace} upgrade -f ${valuesPath} \
--set image.tag=${env.APP_VERSION} \
--install ${k8sAppName} ${helmRepoPath} \
--wait
"""
}
}
}