diff --git a/Jenkinsfile b/Jenkinsfile index 1571162..ef672c5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,7 +32,7 @@ pipeline { } } - stage('Push the Docker Image to DockerHUb') { + stage('Push the Docker Image to DockerHub') { steps { script { withCredentials([string(credentialsId: 'c7783e4f-2f79-482f-885f-dfb39f8c02d3', variable: 'docker_hub')]) { @@ -48,13 +48,52 @@ pipeline { steps { script { kubeconfig(credentialsId: 'k3s-kubeconfig') { - sh 'cat k8s/deployment-test.yaml | sed "s/latest/$BUILD_NUMBER/g" | kubectl apply -n swiss -f -' - sh 'kubectl apply -f k8s/service-test.yaml -n swiss' sh 'cat k8s/deployment.yaml | sed "s/latest/$BUILD_NUMBER/g" | kubectl apply -n swiss -f -' sh 'kubectl apply -f k8s/service.yaml -n swiss' } } } } + stage('Checkout test') { + steps { + // This command checks out the source code from the SCM into the Jenkins workspace + checkout scm + } + } + stage('Build test') { + steps { + sh 'yarn install --no-progress' + sh 'npm run ng build --configuration test' + } + } + + stage('Docker Build test') { + steps { + sh 'docker build -t upquark/swiss-client-test:latest -t upquark/swiss-client-test:${BUILD_NUMBER} .' + } + } + + stage('Push the Docker Image to DockerHub') { + steps { + script { + withCredentials([string(credentialsId: 'c7783e4f-2f79-482f-885f-dfb39f8c02d3', variable: 'docker_hub')]) { + sh 'docker login -u upquark -p ${docker_hub}' + } + sh 'docker push upquark/swiss-client-test:latest' + sh 'docker push upquark/swiss-client-test:${BUILD_NUMBER}' + } + } + } + + stage('Deploy to Kubernetes') { + steps { + script { + kubeconfig(credentialsId: 'k3s-kubeconfig') { + sh 'cat k8s/deployment-test.yaml | sed "s/latest/$BUILD_NUMBER/g" | kubectl apply -n swiss -f -' + sh 'kubectl apply -f k8s/service-test.yaml -n swiss' + } + } + } + } } } diff --git a/angular.json b/angular.json index bc93556..67e4494 100644 --- a/angular.json +++ b/angular.json @@ -69,6 +69,17 @@ "with": "src/environments/environment.development.ts" } ] + }, + "test": { + "optimization": false, + "extractLicenses": false, + "sourceMap": true, + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.test.ts" + } + ] } }, "defaultConfiguration": "production" diff --git a/k8s/deployment-test.yaml b/k8s/deployment-test.yaml index f7f85db..ad30609 100644 --- a/k8s/deployment-test.yaml +++ b/k8s/deployment-test.yaml @@ -14,7 +14,7 @@ spec: spec: containers: - name: swiss-test-client - image: upquark/swiss-client:latest + image: upquark/swiss-client-test:latest imagePullPolicy: Always ports: - containerPort: 4000 diff --git a/src/environments/environment.test.ts b/src/environments/environment.test.ts new file mode 100644 index 0000000..2eb4129 --- /dev/null +++ b/src/environments/environment.test.ts @@ -0,0 +1,4 @@ +export const environment = { + production: false, + backendUrl: "https://backend-test.badminton-toernooi.nl", +}; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 2598d52..78e9c89 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,5 +1,4 @@ export const environment = { production: true, - // backendUrl: "http://swiss-backend.swiss.svc.cluster.local:8080", backendUrl: "https://backend.badminton-toernooi.nl", };