-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
50 lines (43 loc) · 1.17 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
pipeline {
agent {
node {
label 'infra-agent-v3'
}
}
options {
skipDefaultCheckout()
buildDiscarder(logRotator(numToKeepStr: '10'))
timeout(time: 1, unit: 'HOURS')
}
stages {
stage('Checkout') {
when {
expression { env.BRANCH_NAME == 'main'}
}
steps {
checkout scm
}
}
stage('Build Collection') {
when {
expression { env.BRANCH_NAME == 'main'}
}
steps {
sh 'ansible-galaxy collection build'
}
}
stage('Publish Collection') {
when {
expression { env.BRANCH_NAME == 'main'}
}
steps {
withCredentials([string(credentialsId: 'ansible-galaxy-token', variable: 'galaxy_token')]) {
sh """
ARTIFACT=`ls | grep tar.gz`
ansible-galaxy collection publish \$ARTIFACT --token ${galaxy_token}
"""
}
}
}
}
}