forked from dcos/dcos-ansible
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsfile
More file actions
113 lines (105 loc) · 3.48 KB
/
Jenkinsfile
File metadata and controls
113 lines (105 loc) · 3.48 KB
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
@Library('sec_ci_libs@v2-latest') _
def master_branches = ["master", ] as String[]
pipeline {
agent none
environment {
IMAGE = "dcos-ansible-bundle"
// Get credentials for publishing to Docker hub.
DOCKER = credentials('docker-hub-credentials')
}
stages {
stage("Verify author") {
agent {
label "mesos"
}
steps {
user_is_authorized(master_branches, '8b793652-f26a-422f-a9ba-0d1e47eb9d89', '#sre')
}
}
stage('lint') {
agent {
label "py36"
}
steps {
retry(3) {
sh("pip install -r test_requirements.txt")
}
sh("yamllint -c .yamllint.yml .")
sh("ansible-lint roles/")
}
}
stage('molecule test') {
parallel {
stage('molecule test (ec2_centos7)') {
agent {
label "py36"
}
steps {
retry(3) {
sh("pip install -r test_requirements.txt")
}
sh("cp group_vars/all/dcos.yaml.example group_vars/all/dcos.yaml")
// withAWS(credentials:'arn:aws:iam::850970822230:user/jenkins') {
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'arn:aws:iam::850970822230:user/jenkins', accessKeyVariable: 'AWS_ACCESS_KEY_ID', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'],
]) {
retry(3) {
timeout(time: 60, unit: 'MINUTES') {
sh("molecule test --scenario-name ec2_centos7")
}
}
}
}
}
stage('molecule test (ec2_rhel7)') {
agent {
label "py36"
}
steps {
retry(3) {
sh("pip install -r test_requirements.txt")
}
sh("cp group_vars/all/dcos.yaml.example group_vars/all/dcos.yaml")
// withAWS(credentials:'arn:aws:iam::850970822230:user/jenkins') {
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'arn:aws:iam::850970822230:user/jenkins', accessKeyVariable: 'AWS_ACCESS_KEY_ID', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'],
]) {
retry(3) {
timeout(time: 60, unit: 'MINUTES') {
sh("molecule test --scenario-name ec2_rhel7")
}
}
}
}
}
}
}
stage('docker bundle build and publish') {
when {
anyOf {
branch 'master';
branch 'feature/*';
}
}
agent {
label "mesos"
}
steps {
// Login to the Docker registry.
retry(3) {
sh("docker login -u ${DOCKER_USR} -p ${DOCKER_PSW}")
sh("docker build -t mesosphere/${IMAGE}:latest .")
script {
// Calculate Docker image tag based on commit id.
env.dockerTag = sh(script: "echo \$(git rev-parse --abbrev-ref HEAD)-\$(git rev-parse --short HEAD)", returnStdout: true).replaceAll('/','-').trim()
// Tag and push the image we built earlier.
sh("docker tag mesosphere/${IMAGE}:latest mesosphere/${IMAGE}:${env.dockerTag}")
sh("docker push mesosphere/${IMAGE}:${env.dockerTag}")
if (env.BRANCH_NAME == 'master') {
// Only overwrite latest if we're on master
sh("docker push mesosphere/${IMAGE}:latest")
}
}
}
}
}
}
}