diff --git a/Jenkinsfile b/Jenkinsfile index 32ecbda..5878228 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,99 +1,56 @@ pipeline { - agent none - tools{ - jdk 'myjava' - maven 'mymaven' - } - environment{ - IMAGE_NAME='devopstrainer/java-mvn-privaterepos:$BUILD_NUMBER' - DEV_SERVER_IP='ec2-user@13.233.245.74' - APP_NAME='java-mvn-app' + agent any + + parameters{ + string(name:'roshu' ,defaultValue:'Test' ,description: 'version to deploy') + booleanParam(name: 'ExecuteTest', defaultValue: true, description: 'head of the family') + choice(name: 'appversion', choices: ['manadev', 'nandi', 'parvathi'] ) } + stages { - stage('COMPILE') { - agent any - tools{ - jdk 'myjava' - maven 'mymaven' - } + stage('compile') { steps { - script{ - echo "COMPILING THE CODE" - git 'https://github.com/preethid/addressbook.git' - tool name: 'mymaven', type: 'maven' - - sh 'mvn compile' + script { + echo 'compile the code' + echo "roshan garu: ${params.roshu}" } - } } - stage('UNITTEST'){ - agent any - steps { - script{ - echo "RUNNING THE UNIT TEST CASES" - sh 'mvn test' + } + stage('unit test') { + when { + expression { + params.ExecuteTest == true } - } - post{ - always{ - junit 'target/surefire-reports/*.xml' + steps { + script { + echo 'test the code' } } - } - stage('PACKAGE+BUILD DOCKER IMAGE ON BUILD SERVER'){ - agent any - steps{ - script{ - sshagent(['DEV_SERVER']) { - withCredentials([usernamePassword(credentialsId: 'docker-hub', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) { - echo "PACKAGING THE CODE" - sh "scp -o StrictHostKeyChecking=no server-script.sh ${DEV_SERVER_IP}:/home/ec2-user" - sh "ssh -o StrictHostKeyChecking=no ${DEV_SERVER_IP} 'bash ~/server-script.sh'" - sh "ssh ${DEV_SERVER_IP} sudo docker build -t ${IMAGE_NAME} /home/ec2-user/addressbook" - sh "ssh ${DEV_SERVER_IP} sudo docker login -u $USERNAME -p $PASSWORD" - sh "ssh ${DEV_SERVER_IP} sudo docker push ${IMAGE_NAME}" - } - } + } + stage('package') { + steps { + script { + echo 'package the code' + echo "packaging the code versio ${params.shiva}" } } } - stage("Provision deploy server with TF"){ - environment{ - AWS_ACCESS_KEY_ID =credentials("AWS_ACCESS_KEY_ID") - AWS_SECRET_ACCESS_KEY=credentials("AWS_SECRET_ACCESS_KEY") + stage('deploy') { + input { + message "select the version to deploy" + ok "version selected" + parameters { + choice(name: 'newversion', choices: ['1', '2', '3']) } - agent any - steps{ - script{ - dir('terraform'){ - sh "terraform init" - sh "terraform apply --auto-approve" - EC2_PUBLIC_IP = sh( - script: "terraform output ip", - returnStdout: true - ).trim() - } - } - } } - stage('DEPLOY ON EC2 instance'){ - agent any - steps{ - script{ - echo "RUN THE APP ON ec2 instance" - echo "Waiting for ec2 instance to initialise" - sleep(time: 90, unit: "SECONDS") - echo "Deploying the app to ec2-instance provisioned bt TF" - echo "${EC2_PUBLIC_IP}" - sshagent(['DEV_SERVER']) { - withCredentials([usernamePassword(credentialsId: 'docker-hub', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) { - sh "ssh -o StrictHostKeyChecking=no ec2-user@${EC2_PUBLIC_IP} sudo docker login -u $USERNAME -p $PASSWORD" - sh "ssh ec2-user@${EC2_PUBLIC_IP} sudo docker run -itd -p 8080:8080 ${IMAGE_NAME}" - + steps { + script { + echo 'deploy the app' + } } - } - }} + } + } } diff --git a/mahabharat b/mahabharat new file mode 100644 index 0000000..48ad8c0 --- /dev/null +++ b/mahabharat @@ -0,0 +1,3 @@ + +om nama shivaya +hara hara shambho \ No newline at end of file diff --git a/nani b/nani new file mode 100644 index 0000000..9066fa8 --- /dev/null +++ b/nani @@ -0,0 +1 @@ +nani diff --git a/tesssst b/tesssst new file mode 100644 index 0000000..0039e90 --- /dev/null +++ b/tesssst @@ -0,0 +1,2 @@ + malli test tesssst +inko test diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +test diff --git a/webhook tessst b/webhook tessst new file mode 100644 index 0000000..9237be0 --- /dev/null +++ b/webhook tessst @@ -0,0 +1 @@ +webhok tessssss