This repository has been archived by the owner on Sep 28, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
73 lines (72 loc) · 2.71 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
62
63
64
65
66
67
68
69
70
71
72
73
properties([
buildDiscarder(logRotator(artifactDaysToKeepStr: '1', artifactNumToKeepStr: '1', daysToKeepStr: '1', numToKeepStr: '1')),
pipelineTriggers([pollSCM('H/20 * * * *'), [$class: 'PeriodicFolderTrigger', interval: '1d']]),
[$class: 'GithubProjectProperty', displayName: '', projectUrlStr: 'https://github.com/aphex3k/docker-travis-lint/'],
disableConcurrentBuilds()
])
pipeline {
agent any
options { timeout(time: 1, unit: 'HOURS') }
environment {
DOCKER_HUB_USERNAME=credentials('docker_hub_username')
DOCKER_HUB_PASSWORD=credentials('docker_hub_password')
}
tools {
dockerTool 'docker'
}
stages {
stage('Notify') {
steps {
slackSend botUser: true, channel: '@mhenke', color: '#000000', iconEmoji: ':octocat:', message: "started ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)", tokenCredentialId: 'com.slack.mhenke.token', username: 'Octocat'
}
}
stage('Checkout') {
steps {
checkout scm
echo 'Clean'
sh 'git clean -xdf'
}
}
stage ('Build Version') {
steps {
script {
sh 'docker --version'
}
}
}
stage ('Build Dockerimage') {
steps {
script {
sh 'docker build --no-cache -t aphex3k/docker-travis-lint:latest .'
}
}
}
stage ('Travis CI') {
steps {
script {
sh 'docker run --rm -v $(pwd)/:/data/ aphex3k/docker-travis-lint:latest .travis.yml'
}
}
}
stage ('push image') {
when { expression { return env.BRANCH_NAME == 'master' } }
steps {
script {
sh "docker login --username ${DOCKER_HUB_USERNAME} --password ${DOCKER_HUB_PASSWORD}"
sh 'docker image push aphex3k/docker-travis-lint:latest'
}
}
}
}
post {
cleanup {
sh 'git clean -xdf'
}
success {
slackSend botUser: true, channel: '@mhenke', color: '#00ff00', iconEmoji: ':octocat:', message: "succeeded ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)", tokenCredentialId: 'com.slack.mhenke.token', username: 'Octocat'
}
failure {
slackSend botUser: true, channel: '@mhenke', color: '#ff0000', iconEmoji: ':octocat:', message: "failed ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)", tokenCredentialId: 'com.slack.mhenke.token', username: 'Octocat'
}
}
}