diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f02131ce..00dad04c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,8 +4,8 @@ on: pull_request: branches: [ main ] -env: - DATREE_TOKEN: ${{ secrets.DATREE_TOKEN }} +#env: +# DATREE_TOKEN: ${{ secrets.DATREE_TOKEN }} jobs: build: @@ -24,21 +24,6 @@ jobs: run: chmod +x gradlew - name: Build with Gradle run: ./gradlew build - - name: SonarQube Scan - uses: sonarsource/sonarqube-scan-action@master - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - - name: SonarQube Quality Gate check - uses: sonarsource/sonarqube-quality-gate-action@master - # Force to fail step after specific time - timeout-minutes: 5 - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - name: Install Datree - run: curl https://get.datree.io | /bin/bash - - - name: Run Datree's policy check - run: datree test kube.yaml + diff --git a/Jenkinsfile b/Jenkinsfile index a2df42b1..c14b556c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,46 +2,47 @@ pipeline{ agent any environment{ VERSION = "${env.BUILD_ID}" - } + } stages{ stage("sonar quality check"){ - agent { + /* agent { docker { image 'openjdk:11' } - } - steps{ + } */ + steps{ script{ withSonarQubeEnv(credentialsId: 'sonar-token') { sh 'chmod +x gradlew' sh './gradlew sonarqube' } - timeout(time: 1, unit: 'HOURS') { + /* timeout(time: 2, unit: 'MINUTES') { def qg = waitForQualityGate() if (qg.status != 'OK') { error "Pipeline aborted due to quality gate failure: ${qg.status}" } - } + } */ } } - } + } stage("docker build & docker push"){ steps{ script{ + // withCredentials([string(credentialsId: 'docker_pass', variable: 'docker_password')]) withCredentials([string(credentialsId: 'docker_pass', variable: 'docker_password')]) { sh ''' - docker build -t 34.125.214.226:8083/springapp:${VERSION} . - docker login -u admin -p $docker_password 34.125.214.226:8083 - docker push 34.125.214.226:8083/springapp:${VERSION} - docker rmi 34.125.214.226:8083/springapp:${VERSION} + docker build -t 35.222.146.161:8083/springapp:${VERSION} . + docker login -u admin -p $docker_password 35.222.146.161:8083 + docker push 35.222.146.161:8083/springapp:${VERSION} + docker rmi 35.222.146.161:8083/springapp:${VERSION} ''' } } } } - stage('indentifying misconfigs using datree in helm charts'){ + /* stage('indentifying misconfigs using datree in helm charts'){ steps{ script{ @@ -52,7 +53,7 @@ pipeline{ } } } - } + } */ stage("pushing the helm charts to nexus"){ steps{ script{ @@ -61,7 +62,7 @@ pipeline{ sh ''' helmversion=$( helm show chart myapp | grep version | cut -d: -f 2 | tr -d ' ') tar -czvf myapp-${helmversion}.tgz myapp/ - curl -u admin:$docker_password http://34.125.214.226:8081/repository/helm-hosted/ --upload-file myapp-${helmversion}.tgz -v + curl -u admin:$docker_password http://35.222.146.161:8083/repository/helm-hosted/ --upload-file myapp-${helmversion}.tgz -v ''' } } @@ -69,7 +70,7 @@ pipeline{ } } - stage('manual approval'){ + /* stage('manual approval'){ steps{ script{ timeout(10) { @@ -78,21 +79,21 @@ pipeline{ } } } - } + }*/ stage('Deploying application on k8s cluster') { steps { script{ withCredentials([kubeconfigFile(credentialsId: 'kubernetes-config', variable: 'KUBECONFIG')]) { dir('kubernetes/') { - sh 'helm upgrade --install --set image.repository="34.125.214.226:8083/springapp" --set image.tag="${VERSION}" myjavaapp myapp/ ' + sh 'helm upgrade --install --set image.repository="35.222.146.161:8083/springapp" --set image.tag="${VERSION}" myjavaapp myapp/ ' } } } } } - stage('verifying app deployment'){ + /* stage('verifying app deployment'){ steps{ script{ withCredentials([kubeconfigFile(credentialsId: 'kubernetes-config', variable: 'KUBECONFIG')]) { @@ -101,12 +102,12 @@ pipeline{ } } } - } - } + } */ + } - post { + /* post { always { mail bcc: '', body: "
Project: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
URL de build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "${currentBuild.result} CI: Project name -> ${env.JOB_NAME}", to: "deekshith.snsep@gmail.com"; } - } -} + } */ +} \ No newline at end of file diff --git a/kube.yaml b/kube.yaml index d0058111..c8912fc6 100644 --- a/kube.yaml +++ b/kube.yaml @@ -46,7 +46,7 @@ spec: - name: registry-secret containers: - name: myapp - image: imagename + image: ngnix:3.0 command: ["/bin/sh"] args: ["-c","sh /usr/local/tomcat/bin/startup.sh;while true; do echo hello; sleep 10;done"] imagePullPolicy: IfNotPresent diff --git a/kubernetes connect b/kubernetes connect new file mode 100644 index 00000000..1cfed8d4 --- /dev/null +++ b/kubernetes connect @@ -0,0 +1,24 @@ +name: Deploy to Kubernetes + +on: + push: + branches: [ development ] + pull_request: + branches: [ development ] + +jobs: + deploy: + name: Deploy to Kubernetes + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Create kubeconfig + run: | + mkdir ${HOME}/.kube + echo ${{ secrets.KUBE_CONFIG }} | base64 --decode > ${HOME}/.kube/config + cat ${HOME}/.kube/config + - name: Use context + run: kubectl config use-context octobay-api + - name: Deploy to K8s + run: kubectl apply -f k8s/ \ No newline at end of file