-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenksfile.s390x
69 lines (63 loc) · 3.58 KB
/
Jenksfile.s390x
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
pipeline {
agent {
label 's390x'
}
environment {
creds_dockerhub = credentials('dockerhub') // dockerhub is user/pass (token) credential stored as Jenkins cred
creds_rhcatalog = credentials('rhcatalog') // Red Hat catalog is user/pass (token) credential stored as Jenkins cred
image = 'eltondesouza/java-hello-world' // Replace with your [dockerid]/java-hello-world:s390x-latest
registry = 'https://github.com/OpenShift-Z/hello-world-http-java.git' // Replace with your fork of the hello-world code
oc_token = credentials('octoken-s390x') // Replace with OpenShift Token from GUI
platform_arch = 's390x'
platform_tag = "s390x-latest"
ocp_server = 'https://api.ocp1.ocp.local:6443'
registry_server = 'https://cloud.docker.com/v2/repositories'
}
stages {
stage('Pull Source') {
steps {
// more realiable than pull --force. There are better mechanisms for larger code bases
sh 'rm -rf hello-world-http-java'
sh 'git clone $registry'
}
}
stage('Build image') {
steps {
dir('hello-world-http-java') {
// _USR and _PSW are Jenkins inbuild mechanisms to extract user and pass from encrypted credentials
sh 'buildah rmi $image:$platform_tag || true' // cleanup
sh 'buildah rmi $image:latest || true' // cleanup
sh 'podman login registry.redhat.io -u $creds_rhcatalog_USR -p $creds_rhcatalog_PSW' // Pulling official RHEL7 OpenJDK image here
sh 'sudo -n podman build --no-cache=true -t $image:$platform_tag -f Dockerfile '
}
}
}
stage('Pushing image') {
steps {
// _USR and _PSW are Jenkins inbuild mechanisms to extract user and pass from encrypted credentials
sh 'curl -X DELETE -u $creds_dockerhub_USR:$creds_dockerhub_PSW $registry_server/$image:$platform_tag'
sh 'curl -X DELETE -u $creds_dockerhub_USR:$creds_dockerhub_PSW $registry_server/$image:latest'
sh 'podman login docker.io -u $creds_dockerhub_USR -p $creds_dockerhub_PSW'
sh 'sudo -n podman push $image:$platform_tag'
}
}
stage('Amending manifest') {
steps {
sh 'podman login docker.io -u $creds_dockerhub_USR -p $creds_dockerhub_PSW'
sh 'buildah manifest create $image:latest || true'
sh 'buildah manifest add --override-arch=amd64 --override-os=linux --os=linux --arch=$platform_os $image:latest docker://$image:$platform_tag'
}
}
stage('Deploy Image to OpenShift') {
steps {
sh 'oc login --token=$oc_token --insecure-skip-tls-verify --server=$ocp_server'
sh 'oc delete is/java-hello-world || true' // Delete existing stream
sh 'oc delete deploymentconfigs java-hello-world || true' // & deployment config
sh 'oc delete deployment java-hello-world || true' // & deployments config
sh 'oc delete service java-hello-world || true' // & service config
sh 'oc delete route java-hello-world || true' // & service config
sh 'oc new-app $image' // Push new stream
}
}
}
}