-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
80 lines (68 loc) · 1.88 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
72
73
74
75
76
77
78
79
80
pipeline {
triggers {
cron(env.BRANCH_NAME == 'main' ? '@weekly' : '')
}
agent {
label 'Linux && Podman'
}
environment{
IMAGE = "ansible"
TAG = "latest"
FULLIMAGE = "${env.IMAGE}:${env.TAG}"
}
stages {
stage('Initialize') {
parallel {
stage('Advertising start of build') {
steps{
slackSend color: "#4675b1", message: "${env.JOB_NAME} build #${env.BUILD_NUMBER} started :fire: (<${env.RUN_DISPLAY_URL}|Open>)"
}
}
stage('Print environments variables') {
steps {
sh 'printenv | sort'
}
}
stage('Print Podman infos') {
steps {
sh '''
podman version
podman system info
'''
}
}
}
}
stage('Building image') {
steps {
sh 'podman build --pull --network slirp4netns -t $REGISTRY_LOCAL/$FULLIMAGE .'
}
}
stage('Testing image') {
steps {
sh '''
podman run --rm --image-volume ignore --entrypoint \'["ansible","--version"]\' $REGISTRY_LOCAL/$FULLIMAGE
podman run --rm --image-volume ignore --entrypoint \'["ansible-playbook","--version"]\' $REGISTRY_LOCAL/$FULLIMAGE
podman run --rm --image-volume ignore --entrypoint \'["ansible-galaxy","--version"]\' $REGISTRY_LOCAL/$FULLIMAGE
podman run --rm --image-volume ignore --entrypoint \'["ansible-vault","--version"]\' $REGISTRY_LOCAL/$FULLIMAGE
'''
}
}
stage('Pushing image') {
steps {
sh 'podman push $REGISTRY_LOCAL/$FULLIMAGE'
}
}
}
post {
success {
slackSend color: "#4675b1", message: "${env.JOB_NAME} successfully built :blue_heart: !"
}
failure {
slackSend color: "danger", message: "${env.JOB_NAME} build failed :poop: !"
}
cleanup {
cleanWs()
}
}
}