From ea633020490546b0db2e5f5104d6ddb2e327f5dd Mon Sep 17 00:00:00 2001 From: peddoju23 <49018952+peddoju23@users.noreply.github.com> Date: Sat, 15 Aug 2020 17:54:47 +0530 Subject: [PATCH] hhhhh jjjj --- Jenkinsfile | 104 ++++++++++++---------------------------------------- 1 file changed, 24 insertions(+), 80 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6ac0de5bd..490cce5e0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,83 +1,27 @@ -pipeline { -//None parameter in the agent section means that no global agent will be allocated for the entire Pipeline’s -//execution and that each stage directive must specify its own agent section. - agent none - stages { - stage('Build') { - agent { - docker { - //This image parameter (of the agent section’s docker parameter) downloads the python:2-alpine - //Docker image and runs this image as a separate container. The Python container becomes - //the agent that Jenkins uses to run the Build stage of your Pipeline project. - image 'python:2-alpine' +pipleline { + agent none +stages{ + stage('SCM Checkout'){ + agent { + docker{ + git credentialsId: 'GIT_CREDENTIALS', url:https://github.com/peddoju23/myproject.git',branch: 'master' } - } - steps { - //This sh step runs the Python command to compile your application and - //its calc library into byte code files, which are placed into the sources workspace directory - sh 'python -m py_compile sources/add2vals.py sources/calc.py' - //This stash step saves the Python source code and compiled byte code files from the sources - //workspace directory for use in later stages. - stash(name: 'compiled-results', includes: 'sources/*.py*') - } - } - stage('Test') { - agent { - docker { - //This image parameter downloads the qnib:pytest Docker image and runs this image as a - //separate container. The pytest container becomes the agent that Jenkins uses to run the Test - //stage of your Pipeline project. - image 'qnib/pytest' - } - } - steps { - //This sh step executes pytest’s py.test command on sources/test_calc.py, which runs a set of - //unit tests (defined in test_calc.py) on the "calc" library’s add2 function. - //The --junit-xml test-reports/results.xml option makes py.test generate a JUnit XML report, - //which is saved to test-reports/results.xml - sh 'py.test --verbose --junit-xml test-reports/results.xml sources/test_calc.py' - } - post { - always { - //This junit step archives the JUnit XML report (generated by the py.test command above) and - //exposes the results through the Jenkins interface. - //The post section’s always condition that contains this junit step ensures that the step is - //always executed at the completion of the Test stage, regardless of the stage’s outcome. - junit 'test-reports/results.xml' - } - } - } - stage('Deliver') { - agent any - //This environment block defines two variables which will be used later in the 'Deliver' stage. - environment { - VOLUME = '$(pwd)/sources:/src' - IMAGE = 'cdrx/pyinstaller-linux:python2' + } + } + stage('Build') { + agent { + docker{ + image 'python:2-alpine' } - steps { - //This dir step creates a new subdirectory named by the build number. - //The final program will be created in that directory by pyinstaller. - //BUILD_ID is one of the pre-defined Jenkins environment variables. - //This unstash step restores the Python source code and compiled byte - //code files (with .pyc extension) from the previously saved stash. image] - //and runs this image as a separate container. - dir(path: env.BUILD_ID) { - unstash(name: 'compiled-results') + } + steps { + sh 'python -m py_compile source/add2vals.py source/calc.py' + stash(name:'compiled-result',includes: 'sources/*.py*') + } + } + } + } + + + - //This sh step executes the pyinstaller command (in the PyInstaller container) on your simple Python application. - //This bundles your add2vals.py Python application into a single standalone executable file - //and outputs this file to the dist workspace directory (within the Jenkins home directory). - sh "docker run --rm -v ${VOLUME} ${IMAGE} 'pyinstaller -F add2vals.py'" - } - } - post { - success { - //This archiveArtifacts step archives the standalone executable file and exposes this file - //through the Jenkins interface. - archiveArtifacts "${env.BUILD_ID}/sources/dist/add2vals" - sh "docker run --rm -v ${VOLUME} ${IMAGE} 'rm -rf build dist'" - } - } - } - } -}