diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index b6c34792..00000000 --- a/Jenkinsfile +++ /dev/null @@ -1,79 +0,0 @@ -currentBuild.displayName = "Final_Demo # "+currentBuild.number - - def getDockerTag(){ - def tag = sh script: 'git rev-parse HEAD', returnStdout: true - return tag - } - - -pipeline{ - agent any - environment{ - Docker_tag = getDockerTag() - } - - stages{ - - - stage('Quality Gate Statuc Check'){ - - agent { - docker { - image 'maven' - args '-v $HOME/.m2:/root/.m2' - } - } - steps{ - script{ - withSonarQubeEnv('sonarserver') { - sh "mvn sonar:sonar" - } - timeout(time: 1, unit: 'HOURS') { - def qg = waitForQualityGate() - if (qg.status != 'OK') { - error "Pipeline aborted due to quality gate failure: ${qg.status}" - } - } - sh "mvn clean install" - } - } - } - - - - stage('build') - { - steps{ - script{ - sh 'cp -r ../devops-training@2/target .' - sh 'docker build . -t deekshithsn/devops-training:$Docker_tag' - withCredentials([string(credentialsId: 'docker_password', variable: 'docker_password')]) { - - sh 'docker login -u deekshithsn -p $docker_password' - sh 'docker push deekshithsn/devops-training:$Docker_tag' - } - } - } - } - - stage('ansible playbook'){ - steps{ - script{ - sh '''final_tag=$(echo $Docker_tag | tr -d ' ') - echo ${final_tag}test - sed -i "s/docker_tag/$final_tag/g" deployment.yaml - ''' - ansiblePlaybook become: true, installation: 'ansible', inventory: 'hosts', playbook: 'ansible.yaml' - } - } - } - - - - } - - - - - -} diff --git a/jenkinsfile b/jenkinsfile new file mode 100644 index 00000000..22410656 --- /dev/null +++ b/jenkinsfile @@ -0,0 +1,32 @@ +pipeline{ + agent any + stages{ + stage("code analysis"){ + agent{ + docker{ + image:"maven" + } + } + steps{ + script{ + withSonarQubeEnv(credentialsId: 'middle-name') { + sh "mvn sonar:sonar" + } + } + } + } + } + post{ + always{ + echo "========always========" + } + success{ + echo "========pipeline executed successfully ========" + } + failure{ + echo "========pipeline execution failed========" + } + } +} + +