-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
37 lines (32 loc) · 1.3 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
def label = "mypod-${UUID.randomUUID().toString()}"
podTemplate(label: label,
containers: [
containerTemplate(name: 'a-360', image: 'katson95/a-360:latest', ttyEnabled: true, command: 'cat'),
],
volumes: [
hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock')
]) {
node(label) {
checkout scm
def IMAGE_NAME = 'invent360/alpha-agent'
def IMAGE_VERSION = 'latest'
stage('Build and Test Image') {
container('a-360') {
stage('Package into Docker Image') {
sh 'docker build -t alpha-agent:latest .'
sh 'docker tag alpha-agent:latest invent360/alpha-agent:latest'
}
}
}
stage('Publish Image') {
container('a-360'){
stage('Publish Image to Docker Registry') {
withCredentials([usernamePassword(credentialsId: 'docker-hub-credentials-id', passwordVariable: 'dockerPassword', usernameVariable: 'dockerUsername')]) {
sh "docker login -u ${env.dockerUsername} -p ${env.dockerPassword}"
sh "docker push ${IMAGE_NAME}:${IMAGE_VERSION}"
}
}
}
}
}
}