├── .gitignore ├── .mvn ├── extensions.xml └── maven.config ├── .travis.yml ├── CHANGELOG.md ├── Jenkinsfile ├── README ├── README.md ├── docs └── images │ ├── jenkins-config-validation-nok.png │ ├── jenkins-config-validation-ok.png │ ├── jenkins-config.png │ ├── job-config-check.png │ ├── job-config.png │ ├── logo-rundeck.png │ ├── option-provider-artifact.png │ └── option-provider-build.png ├── pom.xml ├── releasing.txt └── src ├── main ├── java │ └── org │ │ └── jenkinsci │ │ └── plugins │ │ └── rundeck │ │ ├── OptionProvider.java │ │ ├── RunDeckLogTail.java │ │ ├── RundeckCause.java │ │ ├── RundeckInstance.java │ │ ├── RundeckInstanceBuilder.java │ │ ├── RundeckJobProjectLinkerAction.java │ │ ├── RundeckNotifier.java │ │ ├── RundeckPlugin.java │ │ ├── RundeckTrigger.java │ │ ├── WebHookListener.java │ │ ├── cache │ │ ├── DummyRundeckJobCache.java │ │ ├── InMemoryRundeckJobCache.java │ │ ├── RundeckJobCache.java │ │ └── RundeckJobCacheConfig.java │ │ ├── client │ │ ├── ExecutionData.java │ │ ├── RundeckClientManager.java │ │ ├── RundeckClientUtil.java │ │ └── RundeckManager.java │ │ └── util │ │ ├── ParseJson.java │ │ └── ParserXML.java ├── resources │ ├── META-INF │ │ └── hudson.remoting.ClassFilter │ ├── index.jelly │ ├── lib │ │ └── rundeck │ │ │ ├── blockWrapper.jelly │ │ │ ├── cellWrapper.jelly │ │ │ ├── rowWrapper.jelly │ │ │ └── taglib │ └── org │ │ └── jenkinsci │ │ └── plugins │ │ └── rundeck │ │ ├── RundeckInstance │ │ └── config.jelly │ │ ├── RundeckJobProjectLinkerAction │ │ └── jobMain.jelly │ │ ├── RundeckNotifier │ │ ├── RundeckExecutionBuildBadgeAction │ │ │ └── badge.jelly │ │ ├── config.jelly │ │ ├── global.jelly │ │ ├── help-includeRundeckLogs.html │ │ ├── help-jobIdentifier.html │ │ ├── help-jobUser.html │ │ ├── help-nodeFilters.html │ │ ├── help-notifyOnAllStatus.html │ │ ├── help-options.html │ │ ├── help-shouldFailTheBuild.html │ │ ├── help-shouldWaitForRundeckJob.html │ │ ├── help-tag.html │ │ └── help-tailLog.html │ │ └── RundeckTrigger │ │ ├── config.jelly │ │ ├── help-executionStatuses.html │ │ ├── help-filterJobs.html │ │ ├── help-identifier.html │ │ ├── help-noFilterJobs.html │ │ └── help.jelly └── webapp │ ├── help-globalConfig-apiversion.html │ ├── help-globalConfig-authtoken.html │ ├── help-globalConfig-login.html │ ├── help-globalConfig-password.html │ ├── help-globalConfig-url.html │ └── images │ ├── rundeck_24x24.png │ └── rundeck_48x48.png └── test ├── groovy └── jenkinsci │ └── plugins │ └── rundeck │ ├── OptionProviderSpec.groovy │ └── RunDeckLogTailSpec.groovy ├── java └── org │ ├── jenkinsci │ └── plugins │ │ └── rundeck │ │ ├── RundeckCauseTest.java │ │ ├── RundeckNotifierBackwardCompatibilityTest.java │ │ ├── RundeckNotifierTest.java │ │ └── WebHookListenerTest.java │ └── rundeck │ └── api │ ├── MockRundeckClient.java │ ├── MockRundeckClientManager.java │ └── MockRundeckInstanceBuilder.java └── resources └── org └── jenkinsci └── plugins └── rundeck ├── RundeckNotifierBackwardCompatibilityTest ├── config.xml ├── jobs │ └── old │ │ └── config.xml └── org.jenkinsci.plugins.rundeck.RundeckNotifier.xml └── empty-svn-repository.zip /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .project 3 | .settings 4 | .factorypath 5 | target 6 | work 7 | 8 | *.iml 9 | .idea/ 10 | -------------------------------------------------------------------------------- /.mvn/extensions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | io.jenkins.tools.incrementals 4 | git-changelist-maven-extension 5 | 1.2 6 | 7 | 8 | -------------------------------------------------------------------------------- /.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -Pconsume-incrementals 2 | -Pmight-produce-incrementals 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | addons: 3 | hosts: 4 | - rdjenkins 5 | hostname: rdjenkins 6 | jdk: 7 | - openjdk8 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## Change Log 2 | 3 | #### Version 3.6.10 (tba) 4 | 5 | - [JENKINS-54537](https://issues.jenkins.io/browse/JENKINS-54537) 6 | Renamed property tags in RundeckNotifier to tagsList to resolve a conflict 7 | between XStream and the Jenkins-Struct-Plugin (String-Array vs String) 8 | 9 | #### Version 3.6.1 (Jan 26, 2017) 10 | 11 | - [JENKINS-34510](https://issues.jenkins-ci.org/browse/JENKINS-34510) 12 | Improve Jenkins startup time and Rundeck jobs generation with 13 | job-dsl thanks to caching (**please note**: it has to be enabled 14 | explicitly in the global config) 15 | - [JENKINS-31423](https://issues.jenkins-ci.org/browse/JENKINS-31423) 16 | Allow build parameters or references to environment variables in 17 | 'Job Identifier' field 18 | - Add Jenkins Pipelines support to Option Provider 19 | - Update RunDeck API Java client library to 13.1 20 | 21 | #### TODO list 22 | 23 | - Internationalization 24 | - Option provider : add integration with the [Promoted Builds 25 | Plugin](http://wiki.jenkins-ci.org/display/JENKINS/Promoted+Builds+Plugin) 26 | and/or [Promoted Builds Simple 27 | Plugin](http://wiki.jenkins-ci.org/display/JENKINS/Promoted+Builds+Simple+Plugin) 28 | so that we can filter only "promoted" builds. 29 | - Use a drop-down field to select the RunDeck job (list of jobs 30 | retrieved using the API) instead of the basic text field 31 | 32 | ### Previous versions 33 | 34 | ##### Version 3.6.0 - skipped 35 | 36 | ##### Version 3.5.4 (May 19, 2016) 37 | 38 | - New: 39 | [JENKINS-22851](https://issues.jenkins-ci.org/browse/JENKINS-31150) 40 | Support multiple Rundeck installations: Configure multiple Rundeck 41 | instances (in the global config), and choose the instance to use in 42 | the job configuration 43 | - New: 44 | [JENKINS-31150](https://issues.jenkins-ci.org/browse/JENKINS-31150) 45 | Support Multiple SCM tags for rundeck notifier 46 | - Fixed: 47 | [JENKINS-28697](https://issues.jenkins-ci.org/browse/JENKINS-28697) 48 | Aborted job is marked as SUCCESS if "Wait for Rundeck" is used 49 | 50 | ##### Version 3.5 (Oct 20, 2015) 51 | 52 | - Use display name for the build name 53 | - Set the build result to failure when rundeck fails AND 54 | shouldFailTheBuild is set to true. Previously only "marked" the 55 | failure; by changing the status of the build to FAIL, other plugins 56 | that might be called after rundeck will then be able to detect the 57 | status, and handle accordingly. 58 | - Fixed bug where log tailer returned completed even though the job 59 | was still running (output was completed). Now both execCompleted and 60 | completed are validated 61 | - Filtered out RundeckOutputEntries with empty messages 62 | - No longer depend on last mod for sleep timing since behaviour seems 63 | to be not aligned with expectations. Now checking if offset has 64 | changed. 65 | - Fixed bug where checkbox wasn't visible in Jenkins 66 | - \[[JENKINS-28059](https://issues.jenkins-ci.org/browse/JENKINS-28059)\] 67 | Validate API version in test connection 68 | 69 | ##### Version 3.4 (Apr 16, 2015) 70 | 71 | - Added support to include Rundeck logs in the Jenkins build log 72 | - Support jobs inside folders 73 | - Fix for Exception when using $ARTIFACT\_NAME 74 | - Fixed: Badge icons fail is jenkins is not root as "/" 75 | - Changed "RunDeck" text items to the correct "Rundeck" 76 | - Updated the Rundeck client to v12.0 \[Fixes 77 | [JENKINS-27971](https://issues.jenkins-ci.org/browse/JENKINS-27971) 78 | — NPE with Rundeck v2.4.2\] 79 | 80 | ##### Version 3.2 (April 15, 2014) 81 | 82 | - Fixed issue with parsing Job options when option values have hyphens 83 | 84 | ##### Version 3.1 (March 29, 2014) 85 | 86 | - Build the URL using the getRootUrl method, which will use the user 87 | configured root url 88 | 89 | ##### Version 3.0 (January 28, 2014) 90 | 91 | - Update rundeck API client lib to latest (9.3) 92 | - Support Token authentication 93 | - Fix authentication against Rundeck running as a war in Tomcat 94 | - Support RDECK\_EXEC\_ARG\_\[NAME\] in triggers from Rundeck webhook 95 | notifications 96 | - Update naming ("RunDeck" changed to "Rundeck"), update icon 97 | 98 | ##### Version 2.11 (January 4, 2012) 99 | 100 | - Fix 101 | [JENKINS-12228](https://issues.jenkins-ci.org/browse/JENKINS-12228) 102 | : allow to filter artifacts returned by the option provider, based 103 | on a java-regex 104 | 105 | ##### Version 2.10 (October 12, 2011) 106 | 107 | - Fix icon path URL - Thanks to [Joe 108 | Passavanti](https://github.com/joepcds) for the 109 | [patch](https://github.com/vbehar/jenkins-rundeck-plugin/pull/2) ! 110 | - Small UI fix : don't display job's ID (in rundeck 1.3+, ID is an 111 | UUID, and it breaks the UI because it is too long) 112 | 113 | ##### Version 2.9 (September 18, 2011) 114 | 115 | - Allow to filter nodes when triggering a rundeck job (using the 116 | "nodeFilters" parameter) 117 | 118 | ##### Version 2.8 (September 16, 2011) 119 | 120 | - Configure RunDeck jobs with either a job ID, or an UUID (rundeck 121 | 1.3+), or a "reference". A job reference is expressed in the format 122 | "project:group/job", for example : 123 | "my-project-name:main-group/sub-group/my-job-name", or 124 | "my-project-name:my-job-name" (for a job without a group). 125 | 126 | ##### Version 2.7 (September 14, 2011) 127 | 128 | - Add a build trigger, using RunDeck 1.3 [WebHook 129 | Notification](http://rundeck.org/docs/RunDeck-Guide.html#webhooks), 130 | so that you can run integration tests with Jenkins after a RunDeck 131 | deployment (alternative to the "Wait for RunDeck job to finish ?" 132 | checkbox in the notifier configuration and a post-build action to 133 | schedule another job) 134 | - Upgrade [RunDeck API Java 135 | client](http://vbehar.github.com/rundeck-api-java-client/) to 136 | version 1.2 137 | 138 | ##### Version 2.6 (September 2, 2011) 139 | 140 | - Add token expansion for $ARTIFACT\_NAME{regex} in options (see 141 | ) 142 | 143 | ##### Version 2.5 (July 11, 2011) 144 | 145 | - Internal refactoring : use the [RunDeck API Java 146 | client](http://vbehar.github.com/rundeck-api-java-client/) 147 | - Never display the RunDeck password in logs (even in case of error) 148 | 149 | ##### Version 2.4 (June 28, 2011) 150 | 151 | - Change Job ID support to use Strings instead of Long, allowing UUIDs 152 | (coming in RunDeck 1.3) - Thanks to [Greg 153 | Schueler](https://github.com/gschueler) for the 154 | [patch](https://github.com/jenkinsci/rundeck-plugin/pull/1) ! 155 | 156 | ##### Version 2.3.1 (June 22, 2011) 157 | 158 | - Fix a bug introduced in version 2.3 : NPE related to the new field 159 | (shouldWaitForRundeckJob) in already configured jobs. Workaround is 160 | to re-save job configuration or use version 2.3.1 161 | 162 | ##### Version 2.3 (June 21, 2011) 163 | 164 | - Add an option to wait for the RunDeck job to finish (by polling the 165 | execution every 5 seconds via the RunDeck API) 166 | - Add a validation button on the job configuration screen, to check 167 | the RunDeck job (display job name, group and project) 168 | 169 | ##### Version 2.2 (June 17, 2011) 170 | 171 | - Add SSL support for RunDeck REST API (trust all certificates and 172 | hosts) 173 | 174 | ##### Version 2.1 (June 8, 2011) 175 | 176 | - New feature : display information about the RunDeck job on the page 177 | of a Jenkins job (with a direct link to the RunDeck job details 178 | webpage) 179 | 180 | ##### Version 2.0.1 (June 8, 2011) 181 | 182 | - Rerelease 2.0 and mark it as incompatible with versions 1.x (jobs 183 | configuration needs to be updated), so that users can see it in the 184 | update-center before updating. 185 | 186 | ##### Version 2.0 (June 6, 2011) 187 | 188 | Compatibility Warning ! 189 | 190 | This version won't work with RunDeck 1.0/1.1, and the configuration per 191 | job has changed, you will need to update the configuration for all your 192 | jobs that use this plugin ! 193 | 194 | - Use the new [RunDeck 1.2+ HTTP REST 195 | API](http://rundeck.org/docs/RunDeck-Guide.html#rundeck-api), and 196 | thus is incompatible with RunDeck 1.0 or RunDeck 1.1 197 | - Use "jobId" to reference RunDeck jobs, instead of the 198 | "groupPath/jobName" couple, so you'll need to reconfigure your 199 | Jenkins jobs. We switched to the "jobId" reference because it is 200 | unique across all projects in a RunDeck instance, which is not the 201 | case for the "groupPath/jobName" couple. 202 | - Set required Jenkins version to 1.400 203 | 204 | ##### Version 1.8 (June 5, 2011) 205 | 206 | - Fix 207 | [JENKINS-9876](https://issues.jenkins-ci.org/browse/JENKINS-9876) : 208 | password field in system configuration should be hidden. 209 | 210 | ##### Version 1.7 (June 1, 2011) 211 | 212 | - New improvement to the option provider : you can now match artifacts 213 | with a java-regex in addition to exact-match of the artifact 214 | filename (see the new 'artifactRegex' parameter). 215 | 216 | ##### Version 1.6 (April 6, 2011) 217 | 218 | - Fix a bug with RunDeck 1.2 : scheduling a job with options did not 219 | work on RunDeck 1.2. 220 | - Set required Jenkins version to 1.399 ([See the thread on the 221 | jenkinsci-dev 222 | mailing-list](http://groups.google.com/group/jenkinsci-dev/msg/26408e6401dd6ee0)). 223 | 224 | ##### Version 1.5.1 (March 24, 2011) 225 | 226 | - Rerelease 1.5 to properly set required Jenkins version ([See the 227 | thread on the jenkinsci-dev 228 | mailing-list](http://groups.google.com/group/jenkinsci-dev/msg/26408e6401dd6ee0)) 229 | : the plugin now depends on Jenkins 1.398 (or higher). 230 | 231 | ##### Version 1.5 (March 4, 2011) 232 | 233 | - Fix bug : when using a "tag" to auto-deploy, we should also check 234 | the SCM changelog from upstream builds. So that you can commit to an 235 | upstream job, and have all downstream jobs redeployed. 236 | 237 | ##### Version 1.4 (March 1, 2011) 238 | 239 | - New improvement to the option provider : in addition to the list of 240 | artifacts for a given build, you can now get the list of builds 241 | (versions) for a given artifact. 242 | 243 | ##### Version 1.3 (February 27, 2011) 244 | 245 | - Jenkins can now be used as an "[Option 246 | provider](http://rundeck.org/docs/RunDeck-Guide.html#option-model-provider)" 247 | for RunDeck, if you want to use your Jenkins build artifacts as an 248 | option to a RunDeck job. 249 | 250 | ##### Version 1.2 (February 27, 2011) 251 | 252 | - Jenkins environment variables specified in the "options" are now 253 | correctly expanded ([GitHub 254 | issue](https://github.com/vbehar/jenkins-rundeck-plugin/issues/1)) 255 | 256 | ##### Version 1.1 (February 11, 2011) 257 | 258 | - Do nothing if the build is failing 259 | - Add a link to the RunDeck job execution page (on each Jenkins 260 | successful build) 261 | - Validation on the form fields (test if RunDeck is alive, test 262 | credentials, etc) 263 | 264 | ##### Version 1.0 (February 10, 2011) 265 | 266 | - Initial release 267 | - Compatible (and tested) with Jenkins 1.396 and RunDeck 1.1 268 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | /* 2 | * See the documentation for more options: 3 | * https://github.com/jenkins-infra/pipeline-library/ 4 | */ 5 | buildPlugin( 6 | forkCount: '1C', // run this number of tests in parallel for faster feedback. If the number terminates with a 'C', the value will be multiplied by the number of available CPU cores 7 | useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests 8 | configurations: [ 9 | [platform: 'linux', jdk: 8], 10 | [platform: 'windows', jdk: 8], 11 | ]) 12 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | Jenkins Rundeck plugin 3 | http://wiki.jenkins-ci.org/display/JENKINS/Rundeck+Plugin 4 | 5 | This plugin is a Jenkins Notifier (Publisher) that will talk to a Rundeck instance (via its HTTP API) to schedule a job execution on Rundeck after a successful build on Jenkins. 6 | It is also a Jenkins Trigger, that will schedule a build on Jenkins after a job execution on Rundeck (using Rundeck WebHook Notification). 7 | In addition, it turns Jenkins into an "Option provider" for Rundeck, if you want to use your Jenkins build artifacts as an option to a Rundeck job. 8 | 9 | We use it to do a 0-click deployment : from commit to deploy, automatically. Jenkins build the project, and Rundeck deploys it. This plugin does the link between these 2 tools. 10 | 11 | * Jenkins : http://www.jenkins-ci.org 12 | * Rundeck : http://www.rundeck.org 13 | * Plugin documentation : http://wiki.jenkins-ci.org/display/JENKINS/Rundeck+Plugin 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Jenkins Rundeck plugin 2 | 3 | This plugin is a Notifier that will talk to a 4 | [Rundeck](http://www.rundeck.org/) instance (via its HTTP API) to 5 | schedule a job execution on Rundeck after a successful build on 6 | Jenkins. 7 | It is also a Trigger that will schedule a build on Jenkins after a job 8 | execution on Rundeck (using Rundeck WebHook Notification). 9 | In addition, it turns Jenkins into an [Option 10 | provider](https://docs.rundeck.com/docs/tutorials/option-provider.html) 11 | for Rundeck, if you want to use your Jenkins build artifacts as an 12 | option to a Rundeck job. 13 | 14 | ![](docs/images/logo-rundeck.png) 15 | 16 | **Table of Contents** 17 | 18 | ## Use 19 | 20 | [Rundeck](https://www.rundeck.com/open-source) is an open-source tool for automating 21 | tasks on multiple nodes, with both a CLI and a web-based interface. You 22 | can use it to deploy your application to multiple nodes/appserv easily. 23 | It has a concept of jobs and build similar to Jenkins. 24 | 25 | You have 3 ways to use this plugin : 26 | 27 | - build a "**deployment pipeline**", (the "0-click deployment 28 | process") : you commit a change, Jenkins picks it up, build, test 29 | and so on, and then triggers a job execution on Rundeck for 30 | deploying your application. This requires some configuration on 31 | Jenkins (both global configuration and job configuration), to link a 32 | Jenkins job with a Rundeck job. 33 | - continue your pipeline after the deployment : Rundeck deploys your 34 | application, then triggers a build on Jenkins to run some 35 | integration tests (Selenium ?). This requires some configuration on 36 | Rundeck (WebHook notification) and on Jenkins (Trigger 37 | configuration, and optionally filter the notifications from 38 | Rundeck). 39 | - use Jenkins as an [**Option 40 | provider**](https://docs.rundeck.com/docs/tutorials/option-provider.html) 41 | for Rundeck : when you execute a Rundeck job, you can have an 42 | (input) option, whose values could be retrieve from an external 43 | system (here, Jenkins). So you can have a Rundeck-job that use a 44 | Jenkins-artifact (from a Jenkins-build) as an input. 45 | 46 | Note that you can combine those use-cases. 47 | 48 | ### Deployment Pipeline 49 | 50 | The goal is to have a **0-click deployment process** : you commit a 51 | change, Jenkins picks it up, build, test and so on, and then triggers a 52 | job execution on Rundeck for deploying your application. 53 | You can also have an "on-demand" process : configure a "tag" in the job 54 | configuration (see below), and the plugin will only notify Rundeck if 55 | the tag is present in the SCM changelog (= in the commit message). 56 | 57 | #### Configuration 58 | 59 | First, you need to configure your Rundeck instance on the main Jenkins 60 | configuration page : 61 | ![](docs/images/jenkins-config.png) 62 | 63 | As of Rundeck plugin version 3.0, you can specify an Authtoken instead 64 | of Login/Password.  Additionally you can set the API version if you need 65 | to use a lower number than the latest version. 66 | 67 | You can use the "Test Connection" button to make sure that Jenkins can 68 | talk to your Rundeck instance : 69 | 70 | | | | 71 | |-------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------| 72 | | ![](docs/images/jenkins-config-validation-nok.png) | ![](docs/images/jenkins-config-validation-ok.png) | 73 | | *Error message in case of error* | *Success message when your credentials are valid* | 74 | 75 | Then, for each Jenkins job, configure the target Rundeck job that should 76 | be executed, along with its options : 77 | 78 | | | | 79 | |------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------| 80 | | ![](docs/images/job-config.png) | ![](docs/images/job-config-check.png) | 81 | | *The per-job configuration screen* | *If set a Job ID, it will display the job details (group, job name and project)* | 82 | 83 | - Note that the "options" should be expressed in the java-properties 84 | format, and that Jenkins environment variables are expanded when 85 | making the Rundeck API calls (for more details, read the 86 | integrated-help in your Jenkins instance by clicking the "?" icon 87 | next to the "options" field). 88 | - The "tag" field is used to perform "on-demand" job scheduling on 89 | Rundeck : if the value is not empty, we will check if the SCM 90 | changelog (= the commit message) contains the given tag, and only 91 | schedule a job execution if it is present. For example you can set 92 | the value to "\#deploy". Note that if this value is left empty, we 93 | will ALWAYS schedule a job execution. 94 | - You can choose to wait for the Rundeck job to finish before 95 | finishing the Jenkins build. Otherwise, the default behavior is to 96 | trigger a Rundeck job, and finish the Jenkins build (usually before 97 | the Rundeck job has ended). 98 | - If the last checkbox is checked, then a failure to schedule the job 99 | execution on Rundeck will fail the Jenkins build. Otherwise, the 100 | Rundeck integration won't interact with the result of your Jenkins 101 | build (even if Rundeck is down). 102 | 103 | ### Post-deployment job 104 | 105 | The goal is to continue the deployment pipeline after a successful 106 | deployment : Rundeck deploys your application, and triggers a build on 107 | Jenkins to run some integration tests (using Selenium for example). 108 | 109 | #### Configuration 110 | 111 | First, you need to configure the [WebHook 112 | Notification](https://docs.rundeck.com/docs/manual/notifications/webhooks.html#job-notifications) in 113 | your Rundeck jobs. Set it to the url 114 | [https://JENKINS\_HOST/plugin/rundeck/webhook/](https://jenkins_host/plugin/rundeck/webhook/). 115 | 116 | Then, configure the "Rundeck Trigger" on your Jenkins jobs : activate 117 | it, and optionally filter the notifications from Rundeck. 118 | 119 | #### Use 120 | 121 | If your Jenkins job is started by a Rundeck notification, you can access 122 | the data of the Rundeck notification as environment variables : 123 | 124 | - **RDECK\_JOB\_ID** : the ID (UUID) of the job 125 | - **RDECK\_JOB\_NAME** : the name of the job 126 | - **RDECK\_JOB\_GROUP** : the group of the job 127 | - **RDECK\_JOB\_DESCRIPTION** : the description of the job 128 | - **RDECK\_PROJECT** : the name of the project 129 | - **RDECK\_EXEC\_ID** : the ID of the execution 130 | - **RDECK\_EXEC\_STATUS** : the status of the execution (one of 131 | SUCCEEDED, FAILED or ABORTED) 132 | - **RDECK\_EXEC\_STARTED\_BY** : the user who started the execution 133 | - **RDECK\_EXEC\_STARTED\_AT** : the date at which the execution 134 | started 135 | - **RDECK\_EXEC\_ENDED\_AT** : the date at which the execution ended 136 | - **RDECK\_EXEC\_ABORTED\_BY** : the user who aborted the execution 137 | (if the status is ABORTED) 138 | - **RDECK\_EXEC\_DURATION\_MILLIS** : the duration of the execution, 139 | in milli-seconds 140 | - **RDECK\_EXEC\_DURATION\_SECONDS** : the duration of the execution, 141 | in seconds 142 | - **RDECK\_EXEC\_DURATION** : the duration of the execution, as a 143 | human-readable string ("3 minutes 34 seconds") 144 | - **RDECK\_EXEC\_SHORT\_DURATION** : the duration of the execution, as 145 | a short human-readable string ("0:03:34.187") 146 | - **RDECK\_EXEC\_URL** : the url of the execution (on the Rundeck Web 147 | GUI) 148 | - **RDECK\_EXEC\_DESCRIPTION** : the description of the execution 149 | - **RDECK\_EXEC\_ARG\_\[NAME\]** : the value of a Job option passed to 150 | the execution *(plugin version 3.0 or later)* 151 | 152 | ### Option Provider 153 | 154 | Using Jenkins as an [Option 155 | provider](https://docs.rundeck.com/docs/tutorials/option-provider.html) 156 | for Rundeck is very easy, because you don't need to configure anything 157 | on the Jenkins side. You just need to point your Rundeck option "remote 158 | url" to one of the following url : 159 | 160 | #### Option Provider for artifacts 161 | 162 | List all artifacts for a given project / build, with a reference to the 163 | absolute url of the artifact. Useful if you have multiple artifacts to 164 | deploy (one per architecture for example). 165 | Example (Rundeck screen when executing a job with an "artifact" option, 166 | taking its values from Jenkins) : 167 | ![](docs/images/option-provider-artifact.png) 168 | 169 | The url : 170 | [https://JENKINS\_HOST/plugin/rundeck/options/artifact](https://jenkins_host/plugin/rundeck/options/artifact) 171 | 172 | - The parameter **project** is mandatory (name of the job) 173 | - The parameter **build** is optional (default value is 'last'). It 174 | could be either a build number, or "last", "lastStable" or 175 | "lastSuccessful". 176 | - The parameter **artifactRegex** is optional. It is a java-regex used 177 | to filter the artifacts to return (if empty, all artifacts will be 178 | returned). 179 | 180 | Example : 181 | https://JENKINS\_HOST/plugin/rundeck/options/artifact?project=my-job&build=lastSuccessful&artifactRegex=.\*\\.war 182 | 183 | #### Option Provider for builds 184 | 185 | List all builds (versions) for a given project / artifact, with a 186 | reference to the absolute url of the artifact. Useful if you have only 1 187 | main artifact, but want to easily re-deploy an older version of the 188 | artifact. 189 | Example (Rundeck screen when executing a job with a "build" option, 190 | taking its values from Jenkins) : 191 | ![](docs/images/option-provider-build.png) 192 | 193 | The url : 194 | [https://JENKINS\_HOST/plugin/rundeck/options/build](https://jenkins_host/plugin/rundeck/options/build) 195 | 196 | - The parameter **project** is mandatory (name of the job) 197 | - Either the parameter **artifact** (exact filename of the artifact) 198 | or **artifactRegex** (java-regex matching the filename of the 199 | artifact) is mandatory 200 | - The parameter **limit** is optional. It should be an integer, and is 201 | used to limit the number of builds (versions) to return. 202 | - The parameters **includeLastStableBuild**, 203 | **includeLastSuccessfulBuild** and **includeLastBuild** are optional 204 | booleans. If it is equals to "true", then we will add an entry for 205 | the last / last stable / last successful build. 206 | 207 | Example : 208 | [https://JENKINS\_HOST/plugin/rundeck/options/build?project=my-job&artifact=my-webapp.war&limit=5&includeLastSuccessfulBuild=true&includeLastStableBuild=true](https://jenkins_host/plugin/rundeck/options/build?project=my-job&artifact=my-webapp.war&limit=5&includeLastSuccessfulBuild=true&includeLastStableBuild=true) 209 | 210 | #### Option Provider Access 211 | 212 | **Note**: Rundeck will call the url anonymously which means the Jenkins 213 | job should provide access to Discover and Read the job. See Matrix based 214 | security 215 | documentation: 216 | 217 | ## Compatibility Matrix 218 | 219 | This plugin is not compatible with all versions of Rundeck 220 | 221 | If you are using Plugin version 3.x and need to access an older Rundeck 222 | server, you can set the API version in the plugin settings. 223 | 224 | You can find older versions of the plugin here : 225 | 226 | 227 | ## FAQ 228 | 229 | #### Known Issues 230 | 231 | - If you have invalid links to Rundeck executions, check your Rundeck 232 | configuration : fix the property "grails.serverURL" in the file 233 | $RDECK\_HOME/server/config/rundeck-config.properties. 234 | - With the versions 1.x of the plugin, you can't have Rundeck jobs 235 | with the same groupPath/jobName on multiple projects. 236 | - Remote options getting 400 server error from Jenkins probably mean 237 | you need to grant anonymous access to Discover and Read the Jenkins 238 | project 239 | 240 | ## Links 241 | 242 | - Sources on github : 243 | - Download binaries (.hpi files): 244 | 245 | -------------------------------------------------------------------------------- /docs/images/jenkins-config-validation-nok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/rundeck-plugin/6355067a782e84590e7790211df5b6a36fc5dd72/docs/images/jenkins-config-validation-nok.png -------------------------------------------------------------------------------- /docs/images/jenkins-config-validation-ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/rundeck-plugin/6355067a782e84590e7790211df5b6a36fc5dd72/docs/images/jenkins-config-validation-ok.png -------------------------------------------------------------------------------- /docs/images/jenkins-config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/rundeck-plugin/6355067a782e84590e7790211df5b6a36fc5dd72/docs/images/jenkins-config.png -------------------------------------------------------------------------------- /docs/images/job-config-check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/rundeck-plugin/6355067a782e84590e7790211df5b6a36fc5dd72/docs/images/job-config-check.png -------------------------------------------------------------------------------- /docs/images/job-config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/rundeck-plugin/6355067a782e84590e7790211df5b6a36fc5dd72/docs/images/job-config.png -------------------------------------------------------------------------------- /docs/images/logo-rundeck.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/rundeck-plugin/6355067a782e84590e7790211df5b6a36fc5dd72/docs/images/logo-rundeck.png -------------------------------------------------------------------------------- /docs/images/option-provider-artifact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/rundeck-plugin/6355067a782e84590e7790211df5b6a36fc5dd72/docs/images/option-provider-artifact.png -------------------------------------------------------------------------------- /docs/images/option-provider-build.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/rundeck-plugin/6355067a782e84590e7790211df5b6a36fc5dd72/docs/images/option-provider-build.png -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.jenkins-ci.plugins 6 | plugin 7 | 4.51 8 | 9 | 10 | 11 | rundeck 12 | ${revision}${changelist} 13 | hpi 14 | 15 | Jenkins Rundeck plugin 16 | Jenkins plugin for Rundeck integration : trigger, notifier and option provider. 17 | https://github.com/jenkinsci/rundeck-plugin 18 | 19 | https://github.com/${gitHubRepo} 20 | scm:git:git://github.com/${gitHubRepo}.git 21 | scm:git:git@github.com:${gitHubRepo}.git 22 | ${scmTag} 23 | 24 | 25 | 26 | 3.6.15 27 | -SNAPSHOT 28 | jenkinsci/rundeck-plugin 29 | 2.346.3 30 | 4.3.0 31 | UTF-8 32 | 2.0 33 | 34 | 35 | 36 | 37 | vbehar 38 | Vincent Behar 39 | 40 | 41 | gschueler 42 | Greg Schueler 43 | greg@simplifyops.com 44 | 45 | 46 | ltamaster 47 | Luis Toledo 48 | luis@variacode.com 49 | 50 | 51 | 52 | 53 | 54 | 55 | central 56 | Maven Central 57 | default 58 | https://repo1.maven.org/maven2 59 | 60 | 61 | repo.jenkins-ci.org 62 | https://repo.jenkins-ci.org/public/ 63 | 64 | 65 | 66 | false 67 | 68 | bintray 69 | bintray 70 | https://jcenter.bintray.com 71 | 72 | 73 | 74 | 75 | 76 | repo.jenkins-ci.org 77 | https://repo.jenkins-ci.org/public/ 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | io.jenkins.tools.bom 87 | bom-2.346.x 88 | 1742.vb_70478c1b_25f 89 | pom 90 | import 91 | 92 | 93 | 94 | xml-apis 95 | xml-apis 96 | 1.4.01 97 | 98 | 99 | com.squareup.okhttp3 100 | okhttp 101 | 4.11.0 102 | 103 | 104 | org.jetbrains.kotlin 105 | kotlin-stdlib-jdk8 106 | 1.6.20 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | org.dom4j 115 | dom4j 116 | 2.1.3 117 | 118 | 119 | 120 | org.rundeck.api 121 | rd-api-client 122 | 2.0.8 123 | 124 | 125 | 126 | 127 | xalan 128 | xalan 129 | 2.7.3 130 | 131 | 132 | xalan 133 | serializer 134 | 2.7.2 135 | 136 | 137 | commons-lang 138 | commons-lang 139 | 2.6 140 | 141 | 142 | io.jenkins.plugins 143 | caffeine-api 144 | 145 | 146 | org.jmockit 147 | jmockit 148 | 1.16 149 | test 150 | 151 | 152 | org.jenkins-ci.plugins 153 | subversion 154 | test 155 | 156 | 157 | org.jenkins-ci.plugins 158 | ssh-credentials 159 | test 160 | 161 | 162 | 163 | org.codehaus.groovy 164 | groovy-all 165 | 2.5.14 166 | pom 167 | test 168 | 169 | 170 | org.apache.ant 171 | ant-launcher 172 | 173 | 174 | jline 175 | jline 176 | 177 | 178 | org.testng 179 | testng 180 | 181 | 182 | 183 | 184 | 185 | cglib 186 | cglib-nodep 187 | 3.3.0 188 | test 189 | 190 | 191 | 192 | cglib 193 | cglib 194 | 3.3.0 195 | test 196 | 197 | 198 | 199 | 200 | org.objenesis 201 | objenesis 202 | 3.3 203 | test 204 | 205 | 206 | 207 | org.spockframework 208 | spock-core 209 | 1.3-groovy-2.5 210 | test 211 | 212 | 213 | 214 | com.google.code.gson 215 | gson 216 | 2.9.0 217 | 218 | 219 | 220 | org.jsoup 221 | jsoup 222 | 1.15.3 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | maven.jenkins-ci.org 232 | https://repo.jenkins-ci.org/releases 233 | 234 | 235 | maven.jenkins-ci.org 236 | https://repo.jenkins-ci.org/snapshots 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | org.codehaus.gmavenplus 245 | gmavenplus-plugin 246 | 247 | 248 | 249 | 250 | compileTests 251 | 252 | 253 | 254 | 255 | 256 | 257 | ${project.basedir}/src/test/groovy 258 | 259 | **/*.groovy 260 | 261 | 262 | 263 | 264 | 265 | 266 | org.jenkins-ci.tools 267 | maven-hpi-plugin 268 | true 269 | 270 | 271 | org.apache.maven.plugins 272 | maven-javadoc-plugin 273 | 274 | 275 | -Xdoclint:none 276 | 277 | 278 | 279 | 280 | maven-surefire-plugin 281 | 3.0.0-M5 282 | 283 | 284 | org.apache.maven.surefire 285 | surefire-junit47 286 | 3.0.0-M5 287 | 288 | 289 | 290 | src/test/groovy 291 | src/test/java 292 | 293 | **/*Spec.java 294 | 295 | **/*Test.java 296 | 297 | 298 | 299 | 300 | 301 | 302 | org.apache.maven.plugins 303 | maven-deploy-plugin 304 | 305 | 306 | org.apache.maven.wagon 307 | wagon-http 308 | 2.10 309 | jar 310 | 311 | 312 | 313 | 314 | org.apache.maven.plugins 315 | maven-compiler-plugin 316 | 3.8.1 317 | 318 | 1.8 319 | 1.8 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | org.eclipse.m2e 328 | lifecycle-mapping 329 | 1.0.0 330 | 331 | 332 | 333 | 334 | 335 | org.apache.maven.plugins 336 | maven-enforcer-plugin 337 | [1.0,) 338 | 339 | display-info 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | org.codehaus.gmaven 349 | gmaven-plugin 350 | [1.3,) 351 | 352 | generateTestStubs 353 | testCompile 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | org.jenkins-ci.tools 363 | maven-hpi-plugin 364 | [1.74,) 365 | 366 | insert-test 367 | resolve-test-dependencies 368 | test-hpl 369 | validate 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | org.jvnet.localizer 379 | maven-localizer-plugin 380 | [1.12,) 381 | 382 | generate 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | -------------------------------------------------------------------------------- /releasing.txt: -------------------------------------------------------------------------------- 1 | 2 | https://wiki.jenkins-ci.org/display/JENKINS/Hosting+Plugins#HostingPlugins-Releasingtojenkinsci.org 3 | 4 | # for ssh to github 5 | 6 | eval `ssh-agent -s` 7 | 8 | 9 | # make sure ~/.m2/settings.xml defines creds for jenkins-ci.org account 10 | 11 | # if encrypted password doesn't work try plain password 12 | 13 | 14 | # use maven 3.0.5 15 | 16 | ## do NOT separate into two commands: 17 | mvn release:prepare release:perform 18 | -------------------------------------------------------------------------------- /src/main/java/org/jenkinsci/plugins/rundeck/OptionProvider.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.rundeck; 2 | 3 | import hudson.Functions; 4 | import hudson.model.Hudson; 5 | import hudson.model.Item; 6 | import hudson.model.ItemGroup; 7 | import hudson.model.Job; 8 | import hudson.model.Run; 9 | import hudson.model.Run.Artifact; 10 | import hudson.model.TopLevelItem; 11 | import hudson.util.RunList; 12 | import java.io.IOException; 13 | import java.io.Serializable; 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | import java.util.regex.Pattern; 17 | import java.util.regex.PatternSyntaxException; 18 | import javax.servlet.http.HttpServletResponse; 19 | import net.sf.json.JSONArray; 20 | import org.apache.commons.lang.StringUtils; 21 | import org.kohsuke.stapler.StaplerRequest; 22 | import org.kohsuke.stapler.StaplerResponse; 23 | 24 | import static hudson.model.Run.ARTIFACTS; 25 | 26 | /** 27 | * Option provider for Rundeck - see http://rundeck.org/docs/manual/jobs.html#option-model-provider 28 | * 29 | * @author Vincent Behar 30 | */ 31 | public class OptionProvider { 32 | 33 | /** 34 | * Provider for artifacts of a specific build, with the name and absolute url of the artifact.
35 | * Mandatory parameter : "project"
36 | * Optional parameters : "build" (either a build number, or "lastStable", "lastSuccessful", "last"), "artifactRegex" 37 | * (java regex used to filter artifacts). 38 | */ 39 | public void doArtifact(StaplerRequest request, StaplerResponse response) throws IOException { 40 | // mandatory parameters 41 | Job project = findProject(request.getParameter("project")); 42 | if (project == null) { 43 | response.sendError(HttpServletResponse.SC_BAD_REQUEST, "You must provide a valid 'project' parameter !"); 44 | return; 45 | } 46 | 47 | // optional parameters 48 | String artifactRegex = request.getParameter("artifactRegex"); 49 | Pattern artifactPattern = null; 50 | if (StringUtils.isNotBlank(artifactRegex)) { 51 | try { 52 | artifactPattern = Pattern.compile(artifactRegex); 53 | } catch (PatternSyntaxException e) { 54 | response.sendError(HttpServletResponse.SC_BAD_REQUEST, 55 | "Invalid java-regex syntax for the 'artifactRegex' parameter : " + e.getMessage()); 56 | return; 57 | } 58 | } 59 | 60 | Run build = findBuild(request.getParameter("build"), project); 61 | if (build == null) { 62 | return; 63 | } 64 | 65 | try { 66 | this.checkArtifactPermissions(build); 67 | }catch (Exception e){ 68 | response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); 69 | return; 70 | } 71 | 72 | List