forked from shclub/edu1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile_dockerhub
52 lines (44 loc) · 2 KB
/
Jenkinsfile_dockerhub
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
def label = "agent-${UUID.randomUUID().toString()}"
def gitBranch = 'master'
def docker_registry = "docker.io"
def imageName = "shclub/edu1"
def TAG = getTag(gitBranch)
podTemplate(label: label, serviceAccount: 'jenkins-admin', namespace: 'edu30',
containers: [
containerTemplate(name: 'podman', image: 'mattermost/podman:1.8.0', ttyEnabled: true, command: 'cat', privileged: true, alwaysPullImage: true)
,containerTemplate(name: 'jnlp', image: 'jenkins/jnlp-slave:latest-jdk11', args: '${computer.jnlpmac} ${computer.name}')
],
volumes: [
hostPathVolume(hostPath: '/etc/containers' , mountPath: '/var/lib/containers' ),
persistentVolumeClaim(mountPath: '/var/jenkins_home', claimName: 'jenkins-edu-slave-pvc',readOnly: false)
]){
//node("podman-agent") {
node(label) {
stage('Clone Git Project') {
sh "pwd"
echo 'Clone'
git branch: 'master', credentialsId: 'github_ci', url: 'https://github.com/shclub/edu1.git'
sh "ls"
}
// podman login -u ${USERNAME} -p ${PASSWORD} --log-level=debug ${docker_registry} --tls-verify=false
stage('Build with Podman') {
container('podman') {
withCredentials([usernamePassword(credentialsId: 'docker_ci',usernameVariable: 'USERNAME',passwordVariable: 'PASSWORD')]) {
sh """
ls -al /etc/containers
podman login -u ${USERNAME} -p ${PASSWORD} --log-level=debug ${docker_registry} --tls-verify=false
podman build -t ${imageName} --cgroup-manager=cgroupfs --tls-verify=false .
podman push ${imageName} --tls-verify=false
echo 'TAG ==========> ' ${imageName}
"""
}
}
}
}
}
def getTag(branchName){
def TAG
def DATETIME_TAG = new Date().format('yyyyMMddHHmmss')
TAG = "${DATETIME_TAG}"
return TAG
}