forked from shclub/edu1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile_test
53 lines (44 loc) · 1.92 KB
/
Jenkinsfile_test
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
def label = "agent-${UUID.randomUUID().toString()}"
def gitBranch = 'master'
def docker_registry = "https://211.252.85.148:40002"
def imageName = "211.252.85.148:40002/edu/edu1"
//공통 환경 변수
def TAG = getTag(gitBranch)
podTemplate(label: label, serviceAccount: 'jenkins-admin', namespace: 'edu2'){
//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: [
// nfsVolume( mountPath: '/', serverAddress: '172.25.1.162', serverPath: '/share_8c0fade2_649f_4ca5_aeaa_8fd57904f8d5/jenkins/edu_slave', 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"
}
stage('Build') {
container('podman') {
withCredentials([usernamePassword(credentialsId: 'harbor_ci',usernameVariable: 'USERNAME',passwordVariable: 'PASSWORD')]) {
sh """
ls -al /etc/containers
podman login -u ${USERNAME} -p ${PASSWORD} ${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 = branchName+"-${DATETIME_TAG}"
TAG = "${DATETIME_TAG}"
return TAG
}