{"id":1818,"date":"2020-04-05T12:36:10","date_gmt":"2020-04-05T09:36:10","guid":{"rendered":"https:\/\/artem.services\/?p=1818"},"modified":"2020-04-05T21:25:07","modified_gmt":"2020-04-05T18:25:07","slug":"jenkins-active-choice-pipeline-%d0%bf%d1%80%d0%b8%d0%bc%d0%b5%d1%80%d1%8b","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=1818","title":{"rendered":"Jenkins &#8212; Active Choice: Pipeline \u043f\u0440\u0438\u043c\u0435\u0440\u044b"},"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>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u043a\u0430\u043a <a href=\"https:\/\/plugins.jenkins.io\/uno-choice\/\" target=\"_blank\" rel=\"noopener noreferrer\">Active Choices<\/a> \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 <strong>Pipeline<\/strong><\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 1<\/h3>\n<p>\u041e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440, \u0438\u0437 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430. \u0412\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0439, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u0431\u0440\u0430\u043d \u043f\u0435\u0440\u0432\u044b\u0439 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<h4>Pipeline:<\/h4>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nproperties([\r\n  parameters([\r\n    [$class: 'CascadeChoiceParameter', \r\n      choiceType: 'PT_SINGLE_SELECT', \r\n      description: 'Select environment',\r\n      filterLength: 1,\r\n      filterable: false,\r\n      name: 'Environment', \r\n      script: [\r\n        $class: 'GroovyScript', \r\n        script: [\r\n          classpath: [], \r\n          sandbox: false, \r\n          script: \r\n            'return[\\'Development\\',\\'Production\\']'\r\n        ]\r\n      ]\r\n    ]\r\n  ])\r\n])\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1819\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.14.00.png\" alt=\"\" width=\"654\" height=\"258\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.14.00.png 654w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.14.00-300x118.png 300w\" sizes=\"(max-width: 654px) 100vw, 654px\" \/><\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1820\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.14.14.png\" alt=\"\" width=\"658\" height=\"264\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.14.14.png 658w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.14.14-300x120.png 300w\" sizes=\"(max-width: 658px) 100vw, 658px\" \/><\/p>\n<h3><\/h3>\n<p><!--more--><\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 2<\/h3>\n<p>\u041e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430. \u0410 \u0442\u0430\u043a \u0436\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 &quot;<strong>Environment<\/strong>&quot;. \u0421\u043a\u0440\u0438\u043f\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u0443\u044e <strong>SSH<\/strong> \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043d\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438, \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0445\u0441\u044f \u0432 &quot;<strong>\/var\/www\/html<\/strong>&quot; \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.<\/p>\n<h4>Pipeline:<\/h4>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nproperties([\r\n  parameters([\r\n    [$class: 'CascadeChoiceParameter', \r\n      choiceType: 'PT_SINGLE_SELECT', \r\n      description: 'Select Site',\r\n      filterLength: 1,\r\n      filterable: false,\r\n      referencedParameters: 'Environment',\r\n      name: 'Site', \r\n      script: [\r\n        $class: 'GroovyScript', \r\n        script: [\r\n          classpath: [], \r\n          sandbox: false, \r\n          script: \r\n            '''if (Environment.equals(&quot;Development&quot;)){\r\n    def command = $\/ssh centos@192.168.1.101 sudo ls \/var\/www\/html \/$\r\n        def proc = command.execute()\r\n        return proc.text.readLines()\r\n}\r\nelse if(Environment.equals(&quot;Production&quot;)){\r\n    def command = $\/ssh centos@192.168.1.102 sudo ls \/var\/www\/html \/$\r\n        def proc = command.execute()\r\n        return proc.text.readLines()\r\n}'''\r\n        ]\r\n      ]\r\n    ]\r\n  ])\r\n])\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1822\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.33.32.png\" alt=\"\" width=\"712\" height=\"424\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.33.32.png 712w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.33.32-300x179.png 300w\" sizes=\"(max-width: 712px) 100vw, 712px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1823\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.33.41.png\" alt=\"\" width=\"682\" height=\"434\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.33.41.png 682w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.33.41-300x191.png 300w\" sizes=\"(max-width: 682px) 100vw, 682px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 3<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 <strong>Active Choice<\/strong> \u0441\u043a\u0440\u0438\u043f\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0432\u044b\u0431\u043e\u0440\u0430, \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 &quot;<strong>Site<\/strong>&quot;. \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0434\u0432\u0443\u0445 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 &#8212; &quot;<strong>referencedParameters: &#39;Environment, Site&#39;<\/strong>&quot;. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430, \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442 \u0438\u0437 \u0432\u044b\u0432\u043e\u0434\u0430 &quot;<strong>..<\/strong>&quot;, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0443\u0434\u0430\u043b\u0438\u043b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0432\u044b\u0448\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439.<\/p>\n<h4>Pipeline:<\/h4>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nproperties([\r\n  parameters([\r\n        [$class: 'CascadeChoiceParameter', \r\n        choiceType: 'PT_SINGLE_SELECT', \r\n        description: 'Select Folder. \\'.\\' - Remove all site folder',\r\n        filterLength: 1,\r\n        filterable: false,\r\n        referencedParameters: 'Environment, Site',\r\n        name: 'Folder', \r\n        script: [\r\n          $class: 'GroovyScript', \r\n          script: [\r\n            classpath: [], \r\n            sandbox: false, \r\n            script: \r\n              '''if (Environment.equals(&quot;Development&quot;)){\r\n    def command = $\/ssh centos@192.168.1.101 sudo ls -a \/var\/www\/html'\/'${Site} | grep -v '\\\\.\\\\.' \/$\r\n        def proc = command.execute()\r\n        return proc.text.readLines()\r\n}\r\nelse if(Environment.equals(&quot;Production&quot;)){\r\n    def command = $\/ssh centos@192.168.1.102 sudo ls -a \/var\/www\/html'\/'${Site} | grep -v '\\\\.\\\\.'\/$\r\n        def proc = command.execute()\r\n        return proc.text.readLines()\r\n}'''\r\n        ]\r\n      ]\r\n    ]\r\n  ])\r\n])\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1827\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.51.00.png\" alt=\"\" width=\"834\" height=\"534\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.51.00.png 834w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.51.00-300x192.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.51.00-768x492.png 768w\" sizes=\"(max-width: 834px) 100vw, 834px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1828\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.51.12.png\" alt=\"\" width=\"714\" height=\"534\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.51.12.png 714w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.51.12-300x224.png 300w\" sizes=\"(max-width: 714px) 100vw, 714px\" \/><\/p>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u0431\u0440\u0430\u043d\u043e &quot;<strong>.<\/strong>&quot;, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d \u0432\u0435\u0441\u044c \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441\u0430\u0439\u0442\u0430.<\/p>\n<p>&nbsp;<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 4<\/h3>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0431\u0443\u043b\u0435\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u0434\u043b\u044f \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.<\/p>\n<h4>Pipeline:<\/h4>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nproperties([\r\n  parameters([\r\n    [$class: 'BooleanParameterDefinition', \r\n      description: 'Set this to confirm deletion',\r\n      name: 'Confirm',\r\n      defaultValue: false\r\n    ]\r\n  ])\r\n])\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1829\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.55.56.png\" alt=\"\" width=\"680\" height=\"608\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.55.56.png 680w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-05-at-12.55.56-300x268.png 300w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u0412\u0435\u0441\u044c <strong>Pipeline<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<h4>Pipeline:<\/h4>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nproperties([\r\n  parameters([\r\n    [$class: 'CascadeChoiceParameter', \r\n      choiceType: 'PT_SINGLE_SELECT', \r\n      description: 'Select environment',\r\n      filterLength: 1,\r\n      filterable: false,\r\n      name: 'Environment', \r\n      script: [\r\n        $class: 'GroovyScript', \r\n        script: [\r\n          classpath: [], \r\n          sandbox: false, \r\n          script: \r\n            'return[\\'Development\\',\\'Production\\']'\r\n        ]\r\n      ]\r\n    ],\r\n    [$class: 'CascadeChoiceParameter', \r\n      choiceType: 'PT_SINGLE_SELECT', \r\n      description: 'Select Site',\r\n      filterLength: 1,\r\n      filterable: false,\r\n      referencedParameters: 'Environment',\r\n      name: 'Site', \r\n      script: [\r\n        $class: 'GroovyScript', \r\n        script: [\r\n          classpath: [], \r\n          sandbox: false, \r\n          script: \r\n            '''if (Environment.equals(&quot;Development&quot;)){\r\n    def command = $\/ssh centos@192.168.1.101 sudo ls \/var\/www\/html \/$\r\n        def proc = command.execute()\r\n        return proc.text.readLines()\r\n}\r\nelse if(Environment.equals(&quot;Production&quot;)){\r\n    def command = $\/ssh centos@192.168.1.102 sudo ls \/var\/www\/html \/$\r\n        def proc = command.execute()\r\n        return proc.text.readLines()\r\n}'''\r\n        ]\r\n      ]\r\n    ],\r\n    [$class: 'CascadeChoiceParameter', \r\n        choiceType: 'PT_SINGLE_SELECT', \r\n        description: 'Select Folder. \\'.\\' - Remove all site folder',\r\n        filterLength: 1,\r\n        filterable: false,\r\n        referencedParameters: 'Environment, Site',\r\n        name: 'Folder', \r\n        script: [\r\n          $class: 'GroovyScript', \r\n          script: [\r\n            classpath: [], \r\n            sandbox: false, \r\n            script: \r\n              '''if (Environment.equals(&quot;Development&quot;)){\r\n    def command = $\/ssh centos@192.168.1.101 sudo ls -a \/var\/www\/html'\/'${Site} | grep -v '\\\\.\\\\.' \/$\r\n        def proc = command.execute()\r\n        return proc.text.readLines()\r\n}\r\nelse if(Environment.equals(&quot;Production&quot;)){\r\n    def command = $\/ssh centos@192.168.1.102 sudo ls -a \/var\/www\/html'\/'${Site} | grep -v '\\\\.\\\\.'\/$\r\n        def proc = command.execute()\r\n        return proc.text.readLines()\r\n}'''\r\n        ]\r\n      ]\r\n    ],\r\n    [$class: 'BooleanParameterDefinition', \r\n      description: 'Set this to confirm deletion',\r\n      name: 'Confirm',\r\n      defaultValue: false\r\n    ]\r\n  ])\r\n])\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u0421\u0430\u043c <strong>Pipeline<\/strong> \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0432 <strong>Slack<\/strong>, \u043e \u0442\u043e\u043c \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c (\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u043b\u0430\u0433\u0438\u043d <a href=\"https:\/\/artem.services\/?p=1805\" target=\"_blank\" rel=\"noopener noreferrer\">user build vars<\/a>) \u043a\u0430\u043a\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0443\u0434\u0430\u043b\u0438\u043b, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<h4>Pipeline:<\/h4>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\npipeline {\r\n  agent any\r\n  options {\r\n    buildDiscarder(logRotator(numToKeepStr: '10'))\r\n    timeout(time: 60, unit:'MINUTES')\r\n    timestamps()\r\n  }\r\n  environment {\r\n    def SSH_USER = 'centos'\r\n    def DEVELOPMENT_INSTANCE = '192.168.1.101'\r\n    def PRODUCTION_INSTANCE = '192.168.1.102'\r\n    def WEB_DIR = '\/var\/www\/html'\r\n    def SLACK_CHANNEL = 'general'\r\n  }\r\n  stages {\r\n    stage('Definition of variables') {\r\n      steps {\r\n        script {\r\n          if ( env.Site.isEmpty() ) {\r\n            echo &quot;Site not specified. If you continue, the www root directory may be deleted.&quot;\r\n            autoCancelled = true\r\n            error('Aborting the build.')\r\n          }\r\n          if ( env.Folder == '.' ) {\r\n            env.FULL_PATH = &quot;${WEB_DIR}\/${Site}&quot;\r\n            echo &quot;Folder not specified&quot;\r\n            echo &quot;Path for delete is: ${FULL_PATH}&quot;\r\n          }          \r\n          else {\r\n            env.FULL_PATH = &quot;${WEB_DIR}\/${Site}\/${Folder}&quot;\r\n            echo &quot;Path for delete is: ${FULL_PATH}&quot;\r\n          }\r\n        }\r\n      }\r\n    }\r\n    stage('Check dir existence') {\r\n      steps {\r\n        script {\r\n          echo &quot;Environment: ${env.Environment}&quot;\r\n          echo &quot;Full path: ${FULL_PATH}&quot;\r\n          if ( env.Environment == 'Development' ) {\r\n            env.EXIST_DIR = sh(script: 'ssh \\${SSH_USER}@\\${DEVELOPMENT_INSTANCE} \\'[ -d \\${FULL_PATH} ] &amp;&amp; echo \\&quot;yes\\&quot; || echo \\&quot;no\\&quot;\\'', returnStdout: true).trim()\r\n            echo &quot;EXIST_DIR: ${EXIST_DIR}&quot;\r\n          }\r\n          else if ( env.Environment == 'Production' ) {\r\n            env.EXIST_DIR = sh(script: 'ssh \\${SSH_USER}@\\${PRODUCTION_INSTANCE} \\'[ -d \\${FULL_PATH} ] &amp;&amp; echo \\&quot;yes\\&quot; || echo \\&quot;no\\&quot;\\'', returnStdout: true).trim()\r\n            echo &quot;EXIST_DIR: ${EXIST_DIR}&quot;\r\n          }\r\n          else {\r\n            echo &quot;Environment not specified&quot;\r\n            autoCancelled = true\r\n            error('Aborting the build.')\r\n          }\r\n          if ( env.EXIST_DIR == 'no' ) {\r\n            echo &quot;Directory: ${FULL_PATH} on ${env.Environment} does not exist&quot;\r\n            autoCancelled = true\r\n            error('Aborting the build.')\r\n          }\r\n        }\r\n      }\r\n    }\r\n    stage('Remove dir') {\r\n      when { expression { return params.Confirm } }\r\n      steps {\r\n        script {\r\n          echo &quot;Remove directory ${FULL_PATH} on ${env.Environment} server&quot;\r\n          if ( env.Environment == 'Development' ) {\r\n            sh &quot;ssh \\${SSH_USER}@\\${DEVELOPMENT_INSTANCE} \\&quot;sudo rm -rf ${FULL_PATH}\\&quot;&quot;\r\n          }\r\n          else if ( env.Environment == 'Production' ) {\r\n            sh &quot;ssh \\${SSH_USER}@\\${PRODUCTION_INSTANCE} \\&quot;sudo rm -rf ${FULL_PATH}\\&quot;&quot;\r\n          }\r\n          else {\r\n            echo &quot;Environment not specified&quot;\r\n            autoCancelled = true\r\n            error('Aborting the build.')\r\n          }\r\n        }\r\n      }\r\n    }\r\n    stage('Output') {\r\n      steps {\r\n        script {\r\n          wrap([$class: 'BuildUser']) {\r\n            if ( env.Confirm.toBoolean() ) {\r\n              echo &quot;Directory ${FULL_PATH} on ${env.Environment} server was deleted by user: ${BUILD_USER}&quot;\r\n              slackSend channel: &quot;${SLACK_CHANNEL}&quot;, color: 'good', message: &quot;Job: ${JOB_NAME} was successful.\\nEnvironment: `${env.Environment}`\\nDirectory: `${FULL_PATH}`\\nState: `Deleted`\\nUser: `${BUILD_USER}`&quot;\r\n            }\r\n            else {\r\n              echo &quot;Directory ${FULL_PATH} on ${env.Environment} server was deleted (Dry run) by user: ${BUILD_USER}&quot;\r\n              slackSend channel: &quot;${SLACK_CHANNEL}&quot;, color: 'good', message: &quot;Job: ${JOB_NAME} was successful.\\nEnvironment: `${env.Environment}`\\nDirectory: `${FULL_PATH}`\\nState: `Dry run`\\nUser: `${BUILD_USER}`&quot;\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }\r\n  }\r\n  post {\r\n    failure {\r\n      slackSend channel: &quot;${SLACK_CHANNEL}&quot;, color: 'danger', message: &quot;Job: ${JOB_NAME} was finished with some error.\\nPlease watch the Jenkins Console Output: ${JOB_URL}${BUILD_ID}\/consoleFull&quot;\r\n    }\r\n    aborted {\r\n      slackSend channel: &quot;${SLACK_CHANNEL}&quot;, color: 'warning', message: &quot;Job: ${JOB_NAME} was canceled.\\nPlease watch the Jenkins Console Output: ${JOB_URL}${BUILD_ID}\/console.&quot;\r\n    }\r\n  }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; \u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u043a\u0430\u043a Active Choices \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 Pipeline \u041f\u0440\u0438\u043c\u0435\u0440 1 \u041e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440, \u0438\u0437 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430. \u0412\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0439, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u0431\u0440\u0430\u043d \u043f\u0435\u0440\u0432\u044b\u0439 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442. Pipeline: &nbsp;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[37],"tags":[1455,125,581],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1818"}],"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=1818"}],"version-history":[{"count":7,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1818\/revisions"}],"predecessor-version":[{"id":1841,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1818\/revisions\/1841"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1818"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1818"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1818"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}