forked from e-desouza/go-hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.amd64
53 lines (52 loc) · 2.12 KB
/
Jenkinsfile.amd64
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
pipeline {
agent {
label 'master'
}
environment {
user_creds = credentials('dockerhub') // dockerhub is user/pass credential stored as Jenkins cred. Token can be used too
image = 'eltondesouza/go-hello-world:amd64-latest' // Replace with your [dockerid]/go-hello-world:s390x-latest
registry = 'https://github.com/e-desouza/go-hello-world.git' // Replace with your fork of the hello-world code
}
stages {
stage('Pull Source') {
steps {
sh 'rm -rf go-hello-world'
sh 'git clone $registry'
}
}
stage('Build image') {
steps {
dir('go-hello-world') {
sh 'sudo -n docker build . -t go-hello-world'
}
}
}
stage('Tagging image') {
steps {
sh 'sudo -n docker tag go-hello-world $image'
}
}
stage('Pushing image') {
steps {
sh 'sudo -n docker login -u $user_creds_USR -p $user_creds_PSW'
sh 'sudo -n docker push $image'
}
}
stage('Amending manifest') {
steps {
sh 'sudo -n docker login -u $user_creds_USR -p $user_creds_PSW'
sh 'export DOCKER_CLI_EXPERIMENTAL=enabled ; sudo -E -n docker manifest create eltondesouza/go-hello-world:latest --amend eltondesouza/go-hello-world:amd64-latest --amend eltondesouza/go-hello-world:s390x-latest'
sh 'export DOCKER_CLI_EXPERIMENTAL=enabled ; sudo -E -n docker manifest push eltondesouza/go-hello-world:latest'
}
}
stage('Deploy Image to OpenShift') {
agent { label 'master' }
steps {
sh 'oc login --token=[replace with OCP token] --server=[replace with OCP server]'
sh 'oc delete is/go-hello-world || true' // Delete existing stream
sh 'oc delete deploymentconfigs go-hello-world || true' // & deployment config
sh 'oc new-app eltondesouza/go-hello-world' // Push new stream
}
}
}
}