forked from AGhost-7/docker-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
77 lines (69 loc) · 1.81 KB
/
Copy pathJenkinsfile
File metadata and controls
77 lines (69 loc) · 1.81 KB
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
74
75
76
77
void setBuildStatus(String message, String state) {
// workaround for: https://issues.jenkins-ci.org/browse/JENKINS-54249
withCredentials([string(credentialsId: 'github-status-access-token', variable: 'TOKEN')]) {
sh """
target_url=\"https://jenkins.jonathan-boudreau.com/blue/organizations/jenkins/docker-dev/detail/docker-dev/$BUILD_NUMBER/pipeline\"
curl \
\"https://api.github.com/repos/AGhost-7/docker-dev/statuses/$GIT_COMMIT\" \
-H \"Authorization: token $TOKEN\" \
-H \"Content-Type: application/json\" \
-H \"Accept: application/vnd.github.v3+json\" \
-XPOST \
-d \"{\\\"description\\\": \\\"$message\\\", \\\"state\\\": \\\"$state\\\", \\\"context\\\": \\\"Jenkins\\\", \\\"target_url\\\": \\\"\$target_url\\\"}\"
"""
}
}
pipeline {
agent {
kubernetes {
defaultContainer 'podman'
yamlFile 'JenkinsPod.yml'
}
}
stages {
stage('set status') {
steps {
setBuildStatus('Build started', 'pending')
}
}
stage('install dependencies') {
steps {
sh 'dnf install -y python-pip git'
sh 'python3 -m pip install virtualenv pytest flake8'
}
}
stage('lint') {
steps {
sh 'flake8'
}
}
stage('test builder') {
steps {
sh 'pytest test_builder.py'
}
}
stage('build images') {
steps {
// For list of options see:
// https://jenkins.io/doc/pipeline/steps/credentials-binding/
withCredentials(bindings: [
usernamePassword(
credentialsId: 'dockerhub',
usernameVariable: 'DOCKERHUB_USERNAME',
passwordVariable: 'DOCKERHUB_PASSWORD'
)]) {
sh 'podman login -u "$DOCKERHUB_USERNAME" -p "$DOCKERHUB_PASSWORD" docker.io'
}
sh 'python3 build.py HEAD'
}
}
}
post {
success {
setBuildStatus("Build succeeded", "success")
}
failure {
setBuildStatus("Build failed", "failure")
}
}
}