DevOps Classroomnotes 23/Jul/2023

Artifactory Jenkins integration contd

  • Create an access token after frog account creation
  • Install artifactory plugin in jenkins
  • Now Navigate to Manage Jenkins -> Credentials and create a credential with secret text

  • Now Navigate to Manage Jenkins -> System -> Jfrog


  • Refer Here for official docs of jfrog artifactory pipelin
  • Refer Here for samples of jfrog jenkins pipelines
  • Refer Here for specific jenkinsfile
  • The pipeline example
pipeline {
    agent { label 'JDK-17' }
    options {
        timeout(time: 30, unit: 'MINUTES')
    }
    triggers {
        pollSCM('* * * * *')
    }
    tools {
        jdk 'JDK_17'
    }
    stages {
        stage('vcs') {
            steps {
                git url: 'https://github.com/dummyrepos/spring-petclinic-1.git',
                    branch: 'develop'
            }
        }
        stage('build and package') {
            steps {
                 rtMavenDeployer (
                    id: "SPC_DEPLOYER",
                    serverId: "JFROG_CLOUD",
                    releaseRepo: 'qt-app-libs-snapshot-local',
                    snapshotRepo: 'qt-app-libs-snapshot-local'
                )
                rtMavenRun (
                    tool: 'MAVEN_3.9', // Tool name from Jenkins configuration
                    pom: 'pom.xml',
                    goals: 'clean install',
                    deployerId: "SPC_DEPLOYER"
                    //,
                    //buildName: "${JOB_NAME}",
                    //buildNumber: "${BUILD_ID}"
                )
                rtPublishBuildInfo (
                    serverId: "JFROG_CLOUD"
                )
            }
        }
        stage('reporting') {
            steps {
                junit testResults: '**/target/surefire-reports/TEST-*.xml'
            }
        }
    }

}

Static code Analysis

  • For static code analysis lets use sonar cloud
  • Refer Here for configuration docs
  • Refer Here to create sonarqube cloud account
  • Now lets create a sonarqube static code analysis
  • Refer Here for configuring and installing sonar qube
  • The pipeline
pipeline {
    agent any
    options {
        timeout(time: 30, unit: 'MINUTES')
    }
    triggers {
        pollSCM('* * * * *')
    }
    tools {
        jdk 'JDK_17_UBUNTU'
        maven 'MAVEN_3.9'
    }
    stages {
        stage('vcs') {
            steps {
                git url: 'https://github.com/dummyrepos/spring-petclinic-1.git',
                    branch: 'develop'
            }
        }
        stage('SonarQube analysis') {
            steps {

                // performing sonarqube analysis with "withSonarQubeENV(<Name of Server configured in Jenkins>)"
                withSonarQubeEnv('SONAR_CLOUD') {
                // requires SonarQube Scanner for Maven 3.2+
                    sh 'mvn clean package sonar:sonar -Dsonar.organization=khajaprojectsjuly23 -Dsonar.token=67d5cbb26a76f3a1c2c669a0d7be62e66722c488 -Dsonar.projectKey=springpetclinic'
                }
            }
        }


        stage('reporting') {
            steps {
                junit testResults: '**/target/surefire-reports/TEST-*.xml'
            }
        }
    }

}

Note: Refer Here for different ecosystem

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Please turn AdBlock off
Social Network Integration by Acurax Social Media Branding Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%