forked from jenkins-x/jx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
111 lines (89 loc) · 4.18 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
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
103
104
105
106
107
108
109
110
111
pipeline {
agent any
environment {
CHARTMUSEUM_CREDS = credentials('jenkins-x-chartmuseum')
JENKINS_CREDS = credentials('test-jenkins-user')
GH_CREDS = credentials('jx-pipeline-git-github-github')
GHE_CREDS = credentials('jx-pipeline-git-github-ghe')
GKE_SA = credentials('gke-sa')
GIT_USERNAME = "$GH_CREDS_USR"
GIT_API_TOKEN = "$GH_CREDS_PSW"
GITHUB_ACCESS_TOKEN = "$GH_CREDS_PSW"
JOB_NAME = "$JOB_NAME"
BRANCH_NAME = "$BRANCH_NAME"
ORG = 'jenkinsxio'
APP_NAME = 'jx'
PREVIEW_VERSION = "0.0.0-SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER"
TEAM = "$BRANCH_NAME-$BUILD_NUMBER".toLowerCase()
PREVIEW_IMAGE_TAG = "SNAPSHOT-JX-$BRANCH_NAME-$BUILD_NUMBER"
// Build and tests configuration (run only 2 builds/tests in parallel
// in order to avoid OOM issue
PARALLEL_BUILDS = 1
// BDD tests configuration
GIT_PROVIDER_URL = "https://github.beescloud.com"
GHE_TOKEN = "$GHE_CREDS_PSW"
GINKGO_ARGS = "-v"
JX_DISABLE_DELETE_APP = "true"
JX_DISABLE_DELETE_REPO = "true"
}
options {
skipDefaultCheckout(true)
}
stages {
stage('CI Build and Test') {
when {
anyOf {
environment name: 'JOB_TYPE', value: 'presubmit'
environment name: 'JOB_TYPE', value: 'batch'
}
}
steps {
dir ('/workspace') {
sh "git config --global credential.helper store"
sh "jx step git credentials"
sh "echo building Pull Request for preview ${TEAM}"
sh "make linux"
sh 'git add . && git diff --exit-code HEAD'
sh "make test-slow-integration"
sh "./build/linux/jx --help"
sh "docker build -t docker.io/$ORG/$APP_NAME:$PREVIEW_VERSION ."
sh "make preview"
// lets create a team for this PR and run the BDD tests
sh "gcloud auth activate-service-account --key-file $GKE_SA"
sh "gcloud container clusters get-credentials anthorse --zone europe-west1-b --project jenkinsx-dev"
sh "sed 's/\$VERSION/${PREVIEW_IMAGE_TAG}/g' myvalues.yaml.template > myvalues.yaml"
sh "echo the myvalues.yaml file is:"
sh "cat myvalues.yaml"
sh "echo creating team: ${TEAM}"
sh "git config --global --add user.name JenkinsXBot"
sh "git config --global --add user.email [email protected]"
sh "cp ./build/linux/jx /usr/bin"
// lets trigger the BDD tests in a new team and git provider
sh "./build/linux/jx step bdd -b --provider=gke --git-provider=ghe --git-provider-url=https://github.beescloud.com --git-username dev1 --git-api-token $GHE_CREDS_PSW --default-admin-password $JENKINS_CREDS_PSW --no-delete-app --no-delete-repo --tests install --tests test-create-spring"
}
}
}
stage('Build and Release') {
when {
environment name: 'JOB_TYPE', value: 'postsubmit'
}
steps {
dir ('/workspace') {
sh "git config --global credential.helper store"
sh "jx step git credentials"
sh "echo \$(jx-release-version) > pkg/version/VERSION"
sh "make release"
}
dir ('/workspace/charts/jx') {
sh "git config --global credential.helper store"
sh "jx step git credentials"
sh "helm init --client-only"
sh "make release"
}
dir ('/workspace') {
sh "updatebot push-version --kind helm jx `cat pkg/version/VERSION`"
}
}
}
}
}