forked from apache/incubator-kie-kogito-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.nightly
102 lines (97 loc) · 4.05 KB
/
Jenkinsfile.nightly
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
pipeline {
agent { label 'operator-slave'}
triggers{
pollSCM(
scmpoll_spec: '@midnight',
ignorePostCommitHooks: true
)
}
options {
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')
timeout(time: 360, unit: 'MINUTES')
}
environment {
WORKING_DIR = "/home/jenkins/go/src/github.com/kiegroup/kogito-cloud-operator/"
GOPATH = "/home/jenkins/go"
GOCACHE = "/home/jenkins/go/.cache/go-build"
}
stages {
stage('Clean Workspace') {
steps {
dir ("${WORKING_DIR}") {
deleteDir()
}
}
}
stage('Initialize') {
steps {
sh "mkdir -p ${WORKING_DIR} && cd ${WORKSPACE} && cp -Rap * ${WORKING_DIR}"
sh "set +x && oc login --token=\$(oc whoami -t) --server=${OPENSHIFT_API} --insecure-skip-tls-verify"
}
}
stage('Build Kogito Operator') {
steps {
dir ("${WORKING_DIR}") {
sh """
export GOROOT=`go env GOROOT`
GO111MODULE=on
go get -u golang.org/x/lint/golint
touch /etc/sub{u,g}id
usermod --add-subuids 10000-75535 \$(whoami)
usermod --add-subgids 10000-75535 \$(whoami)
cat /etc/subuid
cat /etc/subgid
make image_builder=buildah
"""
}
}
}
stage('Build Kogito CLI') {
steps {
dir ("${WORKING_DIR}") {
sh "make build-cli"
}
}
}
stage('Push Operator Image to Openshift Registry') {
steps {
dir ("${WORKING_DIR}") {
sh """
set +x && buildah login -u jenkins -p \$(oc whoami -t) --tls-verify=false ${OPENSHIFT_REGISTRY}
cd version/ && TAG_OPERATOR=\$(grep -m 1 'Version =' version.go) && TAG_OPERATOR=\$(echo \${TAG_OPERATOR#*=} | tr -d '"')
buildah tag quay.io/kiegroup/kogito-cloud-operator:\${TAG_OPERATOR} ${OPENSHIFT_REGISTRY}/openshift/kogito-cloud-operator:pr-\$(echo \${GIT_COMMIT} | cut -c1-7)
buildah push --tls-verify=false docker://${OPENSHIFT_REGISTRY}/openshift/kogito-cloud-operator:pr-\$(echo \${GIT_COMMIT} | cut -c1-7)
"""
}
}
}
stage('Running Testing') {
steps {
dir ("${WORKING_DIR}") {
sh """
make run-smoke-tests load_factor=3 load_default_config=true operator_image=${OPENSHIFT_REGISTRY}/openshift/kogito-cloud-operator operator_tag=pr-\$(echo \${GIT_COMMIT} | cut -c1-7) maven_mirror=${MAVEN_MIRROR_REPOSITORY} concurrent=3
"""
}
}
post {
always {
dir("${WORKING_DIR}") {
archiveArtifacts artifacts: 'test/logs/**/*.log', allowEmptyArchive: true
junit testResults: 'test/logs/**/junit.xml', allowEmptyResults: true
sh "cd test && go run scripts/prune_namespaces.go"
}
}
}
}
stage('Push to Quay') {
steps {
withDockerRegistry([ credentialsId: "quay", url: "https://quay.io" ]) {
sh """
buildah tag ${OPENSHIFT_REGISTRY}/openshift/kogito-cloud-operator:pr-\$(echo \${GIT_COMMIT} | cut -c1-7) quay.io/kiegroup/kogito-cloud-operator-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
buildah push quay.io/kiegroup/kogito-cloud-operator-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
"""
}
}
}
}
}