{"id":2177,"date":"2021-06-23T19:11:59","date_gmt":"2021-06-23T16:11:59","guid":{"rendered":"https:\/\/artem.services\/?p=2177"},"modified":"2021-06-23T19:14:40","modified_gmt":"2021-06-23T16:14:40","slug":"jenkins-python-virtualenv-%d1%81-%d0%b2%d1%8b%d0%b1%d0%be%d1%80%d0%be%d0%bc-%d0%b2%d0%b5%d1%80%d1%81%d0%b8%d0%b9","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=2177","title":{"rendered":"Jenkins &#8212; Python VirtualEnv \u0441 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u0432\u0435\u0440\u0441\u0438\u0439"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-819\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2019\/02\/Jenkins-Logo.png\" alt=\"\" width=\"1280\" height=\"412\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2019\/02\/Jenkins-Logo.png 1280w, https:\/\/artem.services\/wp-content\/uploads\/2019\/02\/Jenkins-Logo-300x97.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2019\/02\/Jenkins-Logo-768x247.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2019\/02\/Jenkins-Logo-1024x330.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2019\/02\/Jenkins-Logo-954x307.png 954w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u0414\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0438\u0442\u043e\u043d\u0430 \u0432 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0435, \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0443\u0436\u043d\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u044b\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435.<\/p>\n<p>\u0414\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0431\u044b\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u043d\u0430 <strong>CentOS 7<\/strong> \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u043e\u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u0430 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e &quot;<strong>\/usr\/bin\/<\/strong>&quot; \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0432\u0435\u0440\u0441\u0438\u0438 &quot;<strong>2.7<\/strong>&quot; \u0438 &quot;<strong>3.6<\/strong>&quot; \u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438.<\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nyum install gcc openssl-devel bzip2-devel libffi-devel wget\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043d\u0443\u0436\u043d\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435: &quot;<strong>3.7<\/strong>&quot;, &quot;<strong>3.8<\/strong>&quot; \u0438 &quot;<strong>3.9<\/strong>&quot;<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncd \/usr\/src\r\n\r\nwget https:\/\/www.python.org\/ftp\/python\/3.7.9\/Python-3.7.9.tgz\r\nwget https:\/\/www.python.org\/ftp\/python\/3.8.9\/Python-3.8.9.tgz\r\nwget https:\/\/www.python.org\/ftp\/python\/3.9.5\/Python-3.9.5.tgz\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u0420\u0430\u0437\u0430\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u0435\u043c:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ntar xzf Python-3.7.9.tgz\r\ntar xzf Python-3.8.9.tgz\r\ntar xzf Python-3.9.5.tgz\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncd Python-3.7.9\r\n.\/configure --enable-optimizations --prefix=\/usr\r\nmake altinstall\r\n\r\ncd ..\/Python-3.8.9\r\n.\/configure --enable-optimizations --prefix=\/usr\r\nmake altinstall\r\n\r\ncd ..\/Python-3.9.5\r\n.\/configure --enable-optimizations --prefix=\/usr\r\nmake altinstall\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043f\u043b\u0430\u0433\u0438\u043d <a href=\"https:\/\/plugins.jenkins.io\/pyenv-pipeline\/\" target=\"_blank\" rel=\"noopener noreferrer\">Pyenv Pipeline<\/a><\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 <strong>Jenkins<\/strong>&#39;\u0430<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1782\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/001.png\" alt=\"\" width=\"349\" height=\"383\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/001.png 349w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/001-273x300.png 273w\" sizes=\"(max-width: 349px) 100vw, 349px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u0420\u0430\u0437\u0434\u0435\u043b &quot;<strong>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u0430\u043c\u0438<\/strong>&quot;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1783\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/002.png\" alt=\"\" width=\"927\" height=\"493\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/002.png 927w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/002-300x160.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/002-768x408.png 768w\" sizes=\"(max-width: 927px) 100vw, 927px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0432\u043a\u043b\u0430\u0434\u043a\u0435 &quot;<strong>\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435<\/strong>&quot; \u0438 \u0432 \u043f\u043e\u0438\u0441\u043a\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c &quot;Pyenv Pipeline&quot;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2178\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.20.45.png\" alt=\"\" width=\"1398\" height=\"160\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.20.45.png 1398w, https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.20.45-300x34.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.20.45-1024x117.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.20.45-768x88.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.20.45-954x109.png 954w, https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.20.45-1354x155.png 1354w\" sizes=\"(max-width: 1398px) 100vw, 1398px\" \/><\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e.<\/p>\n<p>&nbsp;<\/p>\n<p>\u0414\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 &quot;<strong>choice<\/strong>&quot;<\/p>\n<h3>Pipeline:<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nproperties([\r\n  parameters([\r\n    choice(\r\n      name: 'PYTHON',\r\n      description: 'Choose Python version',\r\n      choices: [&quot;python2.7&quot;, &quot;python3.6&quot;, &quot;python3.7&quot;, &quot;python3.8&quot;, &quot;python3.9&quot;].join(&quot;\\n&quot;)\r\n    ),\r\n    base64File(\r\n      name: 'REQUIREMENTS_FILE',\r\n      description: 'Upload requirements file (Optional)'\r\n    )\r\n  ])\r\n])\r\n\r\npipeline {\r\n  agent any\r\n  options {\r\n    buildDiscarder(logRotator(numToKeepStr: '5'))\r\n    timeout(time: 60, unit:'MINUTES')\r\n    timestamps()\r\n  }\r\n  stages {\r\n    stage(&quot;Python&quot;){\r\n      steps{\r\n        withPythonEnv(&quot;\/usr\/bin\/${params.PYTHON}&quot;) {\r\n          script {\r\n            if ( env.REQUIREMENTS_FILE.isEmpty() ) {\r\n              sh &quot;python --version&quot;\r\n              sh &quot;pip --version&quot;\r\n              sh &quot;echo Requirements file not set. Run Python without requirements file.&quot;\r\n            }\r\n            else {\r\n              sh &quot;python --version&quot;\r\n              sh &quot;pip --version&quot;\r\n              sh &quot;echo Requirements file found. Run PIP install using requirements file.&quot;\r\n              withFileParameter('REQUIREMENTS_FILE') {\r\n                sh 'cat $REQUIREMENTS_FILE &gt; requirements.txt'\r\n              }\r\n              sh &quot;pip install -r requirements.txt&quot;\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }\r\n  }\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0431\u043e\u0440\u043a\u0443:<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2179\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.48.39.png\" alt=\"\" width=\"690\" height=\"636\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.48.39.png 690w, https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.48.39-300x277.png 300w\" sizes=\"(max-width: 690px) 100vw, 690px\" \/><\/p>\n<p>\u0412\u044b\u0431\u0435\u0440\u0435\u043c \u043d\u0443\u0436\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 &quot;<strong>3.9<\/strong>&quot; \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u0431\u043e\u0440\u043a\u0443:<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2180\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.48.51.png\" alt=\"\" width=\"628\" height=\"640\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.48.51.png 628w, https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.48.51-294x300.png 294w\" sizes=\"(max-width: 628px) 100vw, 628px\" \/><\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043b\u043e\u0433 \u0441\u0431\u043e\u0440\u043a\u0438:<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2181\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.49.41.png\" alt=\"\" width=\"2110\" height=\"722\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.49.41.png 2110w, https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.49.41-300x103.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.49.41-1024x350.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.49.41-768x263.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.49.41-1536x526.png 1536w, https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.49.41-2048x701.png 2048w, https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.49.41-954x326.png 954w, https:\/\/artem.services\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-23-at-19.49.41-1354x463.png 1354w\" sizes=\"(max-width: 2110px) 100vw, 2110px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; \u0414\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0438\u0442\u043e\u043d\u0430 \u0432 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0435, \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0443\u0436\u043d\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u044b\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0414\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0431\u044b\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u043d\u0430 CentOS 7 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u043e\u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u0430 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e &quot;\/usr\/bin\/&quot; \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0432\u0435\u0440\u0441\u0438\u0438 &quot;2.7&quot; \u0438 &quot;3.6&quot; \u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438. \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438: &nbsp; \u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043d\u0443\u0436\u043d\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439, \u0432 &hellip; <a href=\"https:\/\/artem.services\/?p=2177\" class=\"more-link\">\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u044c<span class=\"screen-reader-text\"> &quot;Jenkins &#8212; Python VirtualEnv \u0441 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u0432\u0435\u0440\u0441\u0438\u0439&quot;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[37],"tags":[125,1121,1771,1159],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/2177"}],"collection":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2177"}],"version-history":[{"count":3,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/2177\/revisions"}],"predecessor-version":[{"id":2184,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/2177\/revisions\/2184"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}