-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
61 lines (57 loc) · 1.68 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
pipeline {
agent any
environment {
// You can create environment variables here.
registryCredential = 'dockerhub'
jenkinsMaster = ''
version = "lts"
linuxSlave = ''
linuxLatest = ''
}
stages {
stage('Setup'){
steps {
sh 'echo "Begin setup"'
git 'https://github.com/plainenough/jenkins'
script {
// You can also create those same variables here.
env.DOCKER_REPO = "derrickwalton" // This should be changed to your username or private repo
env.DOCKER_BASE_NAME = "jenkins"
env.DOCKER_SLAVE_NAME = "jnlp-slave-linux"
}
}
}
stage('Build') {
steps {
sh 'echo "Begin build"'
// Build job just leverages the master to build the docker containers as defined by the docker files in the repo.
script {
masterName = "${env.DOCKER_REPO}/${env.DOCKER_BASE_NAME}:${version}"
jenkinsMaster = docker.build(masterName, "-f ./Dockerfile.Master --no-cache .")
}
script {
slaveName = "${env.DOCKER_REPO}/${env.DOCKER_SLAVE_NAME}:${version}"
linuxSlave = docker.build(slaveName, "-f ./Dockerfile.Slave --no-cache .")
}
}
}
stage('Publish') {
steps {
// Simple usage of a store credential to post to dockerhub.
script {
docker.withRegistry( '', registryCredential ) {
jenkinsMaster.push()
jenkinsMaster.push('latest')
linuxSlave.push()
linuxSlave.push('latest')
}
}
}
}
}
post {
success {
lastChanges since: 'LAST_SUCCESSFUL_BUILD', format:'SIDE',matching: 'LINE'
}
}
}