Skip to content

Commit

Permalink
feat(jenkins): 🎉 add new jenkinsfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhangunduz committed Aug 17, 2023
1 parent 86fca6d commit 81a0c5f
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile-dev
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pipeline {
stage('Build') {
steps {
container('ubuntu') {
withCredentials([file(credentialsId: 'ui_backend_dev', variable: 'text')]) {
withCredentials([file(credentialsId: 'frontend-dev-env', variable: 'text')]) {
writeFile file:'./.env', text: readFile(text)
}
sh 'npm i --force'
Expand Down
11 changes: 3 additions & 8 deletions Jenkinsfile-onpremise → Jenkinsfile-federated-onpremise
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,9 @@ pipeline {
stage('Build') {
steps {
container('ubuntu') {
withCredentials([file(credentialsId: '1f68ce45-857f-416a-9df3-e46712b2d87d', variable: 'text')]) {
withCredentials([file(credentialsId: 'frontend-federated-onpremise-env', variable: 'text')]) {
writeFile file:'./.env', text: readFile(text)
}
withCredentials([file(credentialsId: 'b68b9f5f-0329-4ff1-b1dc-193cb986f15b', variable: 'text')]) {
writeFile file:'./ca.crt', text: readFile(text)
}
sh 'cp ./ca.crt /usr/local/share/ca-certificates/ca.crt'
sh 'update-ca-certificates'
sh 'npm i --force'
sh 'npm run build'
sh "tar -zcvf ui-${env.VER}-${env.BUILD_NUMBER}.tar.gz build"
Expand All @@ -79,11 +74,11 @@ pipeline {
stage('Docker Build') {
steps {
container('docker') {
sh "docker build -t robolaunchio/ui-onpremise-httpd:${env.VER} ."
sh "docker build -t robolaunchio/ui-federated-onpremise-httpd:${env.VER} ."
withCredentials([usernamePassword(credentialsId: 'dockerhub-robolaunchio', passwordVariable: 'password', usernameVariable: 'username')]) {
sh 'docker login -u $username -p $password'
}
sh "docker push robolaunchio/ui-onpremise-httpd:${env.VER}"
sh "docker push robolaunchio/ui-federated-onpremise-httpd:${env.VER}"
}
}
}
Expand Down
94 changes: 94 additions & 0 deletions Jenkinsfile-namespace-onpremise
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
pipeline {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
metadata:
name: kube-pod
spec:
containers:
- name: docker
image: docker:latest
imagePullPolicy: Always
command:
- cat
tty: true
securityContext:
privileged: true
runAsUser: 0
volumeMounts:
- mountPath: /var/run/docker.sock
name: docker-sock
- name: ubuntu
image: robolaunchio/build-image:1.0
imagePullPolicy: Always
command:
- cat
tty: true
env:
- name: CI
value: false
volumes:
- name: docker-sock
hostPath:
path: /var/run/docker.sock
'''
}
}
stages {
stage('Install Deps') {
steps {
container('ubuntu') {
sh 'npm install -g n'
sh 'n latest'
}
}
}
stage('Clone') {
steps {
container('ubuntu') {
git branch: 'main', credentialsId: '7322b7d8-a45e-4594-9bd8-fa1952a7aaad', url: '[email protected]:robolaunch/ui.git'
sh """export VER=`grep '"version":' package.json | awk '{print \$2}' | sed 's/"//g' | sed 's/,//'` && echo \$VER > version.txt"""
script {
env.VER = readFile('version.txt').trim()
}
}
}
}
stage('Build') {
steps {
container('ubuntu') {
withCredentials([file(credentialsId: 'frontend-namespace-onpremise-env', variable: 'text')]) {
writeFile file:'./.env', text: readFile(text)
}
sh 'npm i --force'
sh 'npm run build'
sh "tar -zcvf ui-${env.VER}-${env.BUILD_NUMBER}.tar.gz build"
withCredentials([usernamePassword(credentialsId: '7fadeb6b-976b-40ed-8c7c-20e157b4f81a', passwordVariable: 'password', usernameVariable: 'username')]) {
sh "curl --fail -u $username:$password --upload-file ui-${env.VER}-${env.BUILD_NUMBER}.tar.gz https://nexus.robolaunch.cloud/repository/ui/"
}
}
}
}
stage('Docker Build') {
steps {
container('docker') {
sh "docker build -t robolaunchio/ui-namespace-onpremise-httpd:${env.VER} ."
withCredentials([usernamePassword(credentialsId: 'dockerhub-robolaunchio', passwordVariable: 'password', usernameVariable: 'username')]) {
sh 'docker login -u $username -p $password'
}
sh "docker push robolaunchio/ui-namespace-onpremise-httpd:${env.VER}"
}
}
}
}
post {
always {
emailext to: "[email protected]",
subject: "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}",
body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}",
attachmentsPattern: '*.html'
}
}
}

0 comments on commit 81a0c5f

Please sign in to comment.