[DO-502] add_vault_restore_policy (!43)
Co-authored-by: Rustam Tagaev <rustam.tagaev@avroid.tech> Reviewed-on: https://git.avroid.tech/DevOps/jenkins-pipelines/pulls/43 Reviewed-by: Denis Patrakeev <denis.patrakeev@avroid.team> Co-authored-by: Rustam Tagaev <rustam.tagaev@avroid.team> Co-committed-by: Rustam Tagaev <rustam.tagaev@avroid.team>
This commit is contained in:
committed by
Denis Patrakeev
parent
2eac82a73c
commit
a8d13a4475
@@ -24,7 +24,7 @@ Map projects = [
|
|||||||
],
|
],
|
||||||
'DevOps/ansible': [
|
'DevOps/ansible': [
|
||||||
[
|
[
|
||||||
'branches': [],
|
'branches': ['master'],
|
||||||
'jobs': [
|
'jobs': [
|
||||||
[job: 'Automation/DevOps/vault-policies-and-roles-update']
|
[job: 'Automation/DevOps/vault-policies-and-roles-update']
|
||||||
]
|
]
|
||||||
@@ -32,27 +32,23 @@ Map projects = [
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: "/data"),
|
String getBranch(Map fullJSON) {
|
||||||
yaml: """
|
String branch = ''
|
||||||
apiVersion: v1
|
String refHead = 'refs/heads/'
|
||||||
kind: Pod
|
String refTags = 'refs/tags/'
|
||||||
spec:
|
|
||||||
containers:
|
if (fullJSON.ref != null && fullJSON.ref.contains(refHead)) {
|
||||||
- name: linux
|
branch = fullJSON.ref.split(refHead).last()
|
||||||
image: ${env.JENKINS_DOCKER_REGISTRY}/docker-hub-proxy/library/alpine:3.18.5
|
} else if (fullJSON.ref != null && fullJSON.ref.contains(refTags)) {
|
||||||
command:
|
branch = fullJSON.ref.split(refTags).last()
|
||||||
- sleep
|
} else if (fullJSON.ref != null) {
|
||||||
args:
|
branch = fullJSON.ref
|
||||||
- 99d
|
}
|
||||||
resources:
|
|
||||||
limits:
|
return branch
|
||||||
cpu: 100m
|
}
|
||||||
memory: 64Mi
|
|
||||||
requests:
|
podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: "/data"), yaml: getPodTemplate('alpine')) {
|
||||||
cpu: 100m
|
|
||||||
memory: 64Mi
|
|
||||||
"""
|
|
||||||
) {
|
|
||||||
node(POD_LABEL) {
|
node(POD_LABEL) {
|
||||||
stage('Run job') {
|
stage('Run job') {
|
||||||
try {
|
try {
|
||||||
@@ -60,32 +56,25 @@ podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: "/data"),
|
|||||||
String projectName = fullJSON.repository.full_name
|
String projectName = fullJSON.repository.full_name
|
||||||
currentBuild.description = "Repo: ${fullJSON.repository.full_name}"
|
currentBuild.description = "Repo: ${fullJSON.repository.full_name}"
|
||||||
currentBuild.displayName = "#${env.BUILD_ID} Skip"
|
currentBuild.displayName = "#${env.BUILD_ID} Skip"
|
||||||
|
|
||||||
//info for Debug
|
//info for Debug
|
||||||
//println(fullJSON)
|
//println(fullJSON)
|
||||||
if (fullJSON.ref) {
|
if (projects[projectName]) {
|
||||||
String branch = ''
|
String branch = getBranch(fullJSON)
|
||||||
currentBuild.description = "Repo: ${fullJSON.repository.full_name} $branch"
|
|
||||||
String refHead = 'refs/heads/'
|
|
||||||
String refTags = 'refs/tags/'
|
|
||||||
|
|
||||||
if (fullJSON.ref.contains(refHead)) {
|
currentBuild.description = "Repo: ${fullJSON.repository.full_name} $branch"
|
||||||
branch = fullJSON.ref.split(refHead).last()
|
|
||||||
} else {
|
|
||||||
branch = fullJSON.ref.split(refTags).last()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check project in map and start to work with it
|
// Check project in map and start to work with it
|
||||||
projects[projectName].each { Map project ->
|
projects[projectName].each { Map project ->
|
||||||
currentBuild.displayName = "#${env.BUILD_ID} Run for branches"
|
currentBuild.displayName = "#${env.BUILD_ID} Run for all branches"
|
||||||
|
|
||||||
project.jobs.each { Map job ->
|
project.jobs.each { Map job ->
|
||||||
build job: job.job,
|
build job: job.job,
|
||||||
parameters: [
|
parameters: [
|
||||||
string(name: 'PROJECT_NAME', value: projectName),
|
string(name: 'PROJECT_NAME', value: projectName),
|
||||||
string(name: 'BRANCH_NAME', value: branch),
|
string(name: 'BRANCH_NAME', value: branch),
|
||||||
string(name: 'DATA_JSON', value: fullJSON.toString())
|
string(name: 'DATA_JSON', value: fullJSON.toString())
|
||||||
],
|
],
|
||||||
wait: false
|
wait: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user