{"id":1053,"date":"2019-04-25T16:42:25","date_gmt":"2019-04-25T13:42:25","guid":{"rendered":"https:\/\/artem.services\/?p=1053"},"modified":"2020-03-24T17:50:44","modified_gmt":"2020-03-24T14:50:44","slug":"jenkins-%d0%bd%d0%b0%d0%b3%d1%80%d1%83%d0%b7%d0%be%d1%87%d0%bd%d0%be%d0%b5-%d1%82%d0%b5%d1%81%d1%82%d0%b8%d1%80%d0%be%d0%b2%d0%b0%d0%bd%d0%b8%d0%b5-jmeterantslack","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=1053","title":{"rendered":"Jenkins &#8212; \u041d\u0430\u0433\u0440\u0443\u0437\u043e\u0447\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (JMeter+Ant+Slack)"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"alignnone 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>\u041d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 <strong>Jenkins<\/strong> \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c <a href=\"https:\/\/jmeter.apache.org\/download_jmeter.cgi\" target=\"_blank\" rel=\"noopener noreferrer\">JMeter<\/a><\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f <a href=\"https:\/\/jmeter-plugins.org\/?search=jpgc-cmd\" target=\"_blank\" rel=\"noopener noreferrer\">JMeterPluginsCMD<\/a><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmkdir -p \/var\/lib\/jmeter\r\n<\/pre>\n<p>\u0421\u043a\u0430\u0447\u0430\u0435\u043c \u0438 \u0440\u0430\u0437\u0430\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u0432 \u044d\u0442\u0443 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0434\u0432\u0443\u0445 \u0430\u0440\u0445\u0438\u0432\u043e\u0432.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0431\u044b\u043b\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@jenkins:~# ll \/var\/lib\/jmeter\/\r\ntotal 64K\r\ndrwxr-xr-x  8 jenkins jenkins 4.0K Apr 24 15:39 .\r\ndrwxr-xr-x 37 root    root    4.0K Mar 22 10:29 ..\r\ndrwxr-xr-x  5 jenkins jenkins 4.0K Apr 24 17:47 bin\r\ndrwxr-xr-x  5 jenkins jenkins 4.0K Mar 10 08:41 docs\r\ndrwxr-xr-x  2 jenkins jenkins 4.0K Mar 10 08:43 extras\r\ndrwxr-xr-x  4 jenkins jenkins 4.0K Apr 24 17:47 lib\r\n-rw-r--r--  1 jenkins jenkins  15K Mar 10 10:08 LICENSE\r\ndrwxr-xr-x  4 jenkins jenkins 4.0K Mar 10 10:08 licenses\r\n-rw-r--r--  1 jenkins jenkins  172 Mar 10 10:08 NOTICE\r\ndrwxr-xr-x  6 jenkins jenkins 4.0K Mar 10 09:58 printable_docs\r\n-rw-r--r--  1 jenkins jenkins  10K Mar 10 10:08 README.md\r\n<\/pre>\n<p><!--more--><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c <a href=\"https:\/\/artem.services\/wp-content\/uploads\/2019\/04\/Jenkins-JMeter.zip\">\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c<\/a>.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432 <strong>Jenkins<\/strong>&#39;\u0435 Item \u0434\u043b\u044f <strong>Multibranch Pipeline<\/strong>.<\/p>\n<p>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <strong>Jenkinsfile<\/strong>:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\npipeline {\r\n    agent any\r\n    parameters {\r\n        string(name: 'SERVER_URL', defaultValue: 'example.org', description: 'URL for load test')\r\n        string(name: 'SITE_PATH', defaultValue: '\/', description: 'Path for URL. Default - &quot;\/&quot;')\r\n        string(name: 'NUMBER_OF_THREADS', defaultValue: '10', description: 'Number of Threads (Users). Default - 10')\r\n        string(name: 'RAMP_TIME', defaultValue: '5', description: 'Ramp-Up Period. Default - 5(sec)')\r\n        string(name: 'DURATION_TIME', defaultValue: '5', description: 'Duration (seconds). Default - 5')\r\n        string(name: 'STARTUP_DELAY', defaultValue: '5', description: 'Startup delay (seconds). Default - 5')\r\n        booleanParam(name: 'DELETE_CACHE', defaultValue: false, description: 'Toggle this value to build with cache clearing.')\r\n    }\r\n    options {\r\n        ansiColor('xterm')\r\n        timeout(time: 30, unit:'MINUTES')\r\n        timestamps()\r\n    }\r\n    environment {\r\n        def ANT = '\/usr\/bin\/ant'\r\n        def JMETER = '\/var\/lib\/jmeter\/bin\/jmeter'\r\n        def JMETER_HOME = '\/var\/lib\/jmeter\/'\r\n        def TEMPLATE = 'SITE_SIMPLE.jmx'\r\n        \/\/ Perository\r\n        def GIT_REPO = 'https:\/\/git.artem.services\/scm\/dev\/jenkins-jmeter.git'\r\n        def GIT_CRED = 'svc-bitbucket'\r\n        \/\/ Slack\r\n        def SLACK_CHANNEL_ID = credentials('artem-slack-channel-id-debug')\r\n        def SLACK_TOKEN = credentials('artem-slack-token')\r\n        def GIF_SUCCESS = giphySearchRandomByKeyword(credentialsId: 'giphy-api-key', keyword: &quot;hacker&quot;, rating: 'g', imageSize: 'downsized_medium')\r\n    }\r\n    stages {\r\n        stage ('Delete work dir') {\r\n            when { expression { return params.DELETE_CACHE } }\r\n            steps {\r\n                deleteDir()\r\n                git branch: &quot;${BRANCH_NAME}&quot;, credentialsId: &quot;${GIT_CRED}&quot;, url: &quot;${GIT_REPO}&quot;\r\n            }\r\n        }      \r\n        stage ('Configure template') {\r\n            when { branch 'master' }\r\n            steps {\r\n                sh 'envsubst &lt; &quot;ant\/templates\/\\&quot;${TEMPLATE}\\&quot;&quot; &gt; &quot;ant\/templates\/\\&quot;${TEMPLATE}\\&quot;.tmp&quot;'\r\n                sh 'envsubst &lt; &quot;ant\/build\/build.properties&quot; &gt; &quot;ant\/build.properties&quot;'\r\n            }\r\n        }\r\n        stage ('Load test') {\r\n            when { branch 'master' }\r\n            steps {\r\n                sh &quot;cd ant &amp;&amp; ${ANT} clean&quot;\r\n                sh &quot;cd ant &amp;&amp; ${ANT} run&quot;\r\n                sh &quot;cd ant &amp;&amp; ${ANT} generate-report&quot;\r\n                sh &quot;cd ant &amp;&amp; ${ANT} generate-chart&quot;\r\n                sh &quot;wget ${GIF_SUCCESS} -O ant\/result\/success.gif&quot;\r\n            }\r\n        }\r\n    } \r\n    post {\r\n        always {\r\n            sh &quot;rm ant\/templates\/${TEMPLATE}.tmp | true&quot;\r\n            sh &quot;rm ant\/build.properties | true&quot;\r\n        }\r\n        success {\r\n            slackSend channel: &quot;${SLACK_CHANNEL_ID}&quot;, color: 'good', message: &quot;Perfomance test domain: `\\&quot;${SERVER_URL}\\&quot;` was successful.&quot;\r\n            script {\r\n                sh &quot;chmod +x .\/upload_images.sh&quot;\r\n                sh &quot;.\/upload_images.sh ${SLACK_CHANNEL_ID} ${SLACK_TOKEN}&quot;\r\n            }\r\n        }\r\n        failure {\r\n            slackSend channel: &quot;${SLACK_CHANNEL_ID}&quot;, color: 'danger', message: &quot;Perfomance test domain: `\\&quot;${SERVER_URL}\\&quot;` was finished with some error. Watch the Jenkins Console Output: ${JOB_URL}${BUILD_ID}\/consoleFull&quot;\r\n        }\r\n    }\r\n}\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Item \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043e\u0447\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043e\u0442\u0447\u0435\u0442 \u0438 png \u0433\u0440\u0430\u0444\u0438\u043a\u0438, \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u0432 <strong>Slack<\/strong> \u043a\u0430\u043d\u0430\u043b. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c <strong>Item<\/strong>&#39;\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/jenkinsci\/pipeline-giphy-api-plugin\" target=\"_blank\" rel=\"noopener noreferrer\">Giphy Plugin<\/a>, \u0438\u043b\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u0435\u0433\u043e, \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u0435 \u0435\u0433\u043e \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 &quot;<strong>Jenkinsfile<\/strong>&quot; \u0438 &quot;<strong>upload_images.sh<\/strong>&quot;<\/p>\n<p>\u0414\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b &quot;<strong>ant generate-chart<\/strong>&quot; \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u044b, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nant install-plugins\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<p><img loading=\"lazy\" class=\"size-full wp-image-1059 aligncenter\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2019\/04\/Screen-Shot-2019-04-25-at-6.29.52-PM.png\" alt=\"\" width=\"978\" height=\"1252\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2019\/04\/Screen-Shot-2019-04-25-at-6.29.52-PM.png 978w, https:\/\/artem.services\/wp-content\/uploads\/2019\/04\/Screen-Shot-2019-04-25-at-6.29.52-PM-234x300.png 234w, https:\/\/artem.services\/wp-content\/uploads\/2019\/04\/Screen-Shot-2019-04-25-at-6.29.52-PM-768x983.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2019\/04\/Screen-Shot-2019-04-25-at-6.29.52-PM-800x1024.png 800w, https:\/\/artem.services\/wp-content\/uploads\/2019\/04\/Screen-Shot-2019-04-25-at-6.29.52-PM-954x1221.png 954w\" sizes=\"(max-width: 978px) 100vw, 978px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 Jenkins \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c JMeter \u0422\u0430\u043a \u0436\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f JMeterPluginsCMD \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f: \u0421\u043a\u0430\u0447\u0430\u0435\u043c \u0438 \u0440\u0430\u0437\u0430\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u0432 \u044d\u0442\u0443 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0434\u0432\u0443\u0445 \u0430\u0440\u0445\u0438\u0432\u043e\u0432. \u0427\u0442\u043e\u0431\u044b \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0431\u044b\u043b\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[37],"tags":[795,125,793,66],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1053"}],"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=1053"}],"version-history":[{"count":9,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1053\/revisions"}],"predecessor-version":[{"id":1754,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1053\/revisions\/1754"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}