-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
71 lines (64 loc) · 1.85 KB
/
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
#!/usr/bin/env groovy
@Library('devops-dsl')_
def build
def resourcesToBuild = []
def notifyChannel = "aws-s3-list-notification"
def slackMessage = """
Pipeline : AWS S3 Bucket List Pipeline
Job : ${env.JOB_NAME} [${env.BUILD_NUMBER}]
ConsoleOutput: <${env.BUILD_URL}|${env.JOB_NAME} [#${env.BUILD_NUMBER}]>
"""
pipeline {
agent {
docker {
alwaysPull true
image "aws-cli:latest" // Change to appropriate AWS CLI image
label "aws-cli"
args "--net host"
}
}
options {
disableResume()
disableConcurrentBuilds()
timestamps()
ansiColor('xterm')
}
stages {
stage('Build') {
steps {
script {
println("Loading common build functions")
build = load "$WORKSPACE/build/pipelines/build_functions.groovy"
}
}
}
stage('Fetch Account Directories') {
steps {
script {
deployment_dir = "src/accounts" // Directory containing account information
resourcesToBuild = build.massDeployCloudManagementRole(deployment_dir)
}
}
}
stage("List S3 Buckets") {
steps {
script {
assume_arn = "arn:aws:iam::666666666:role/cross-account-role" // Your cross-account role
build.parallelBuild(resourcesToBuild, "list", assume_arn)
}
}
}
}
post {
always {
echo 'Cleaning up workspace'
cleanWs()
}
success {
slackNotify("${notifyChannel}", "*SUCCESS*\n${slackMessage}")
}
failure {
slackNotify("${notifyChannel}", "*FAILURE*\n${slackMessage}")
}
}
}