Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-28632

Workflow support for Deployment Notification trigger

      DeploymentTrigger should be a Trigger<ParameterizedJob> so as to support non-AbstractProject including WorkflowJob.

          [JENKINS-28632] Workflow support for Deployment Notification trigger

          Code changed in jenkins
          User: Jesse Glick
          Path:
          COMPATIBILITY.md
          http://jenkins-ci.org/commit/workflow-plugin/502baeecf856ec112a265663ff75d4cb4e82affe
          Log:
          JENKINS-28632 Noting.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: COMPATIBILITY.md http://jenkins-ci.org/commit/workflow-plugin/502baeecf856ec112a265663ff75d4cb4e82affe Log: JENKINS-28632 Noting.

          Jesse Glick added a comment -

          Triggering a downstream Workflow job would be useful, but then you are back to job chaining, so you do not get the benefit of having all the logic in one script. What is crucially missing is a way for a Workflow step to pause until it gets a deployment event. You could perhaps cobble this together in a prototype using the generic waitUntil step and calling a couple of Jenkins APIs to inspect current fingerprints looking for DeploymentFacet, though I do not see a way to find these facets efficiently if you do not already have the MD5 checksum of the event, and anyway this would be polling rather than responding immediately.

          The proper solution is to have a dedicated Workflow step which registers a DeploymentFacetListener that listens for the equivalent of ThresholdCondition but matching the current build. (There is no “upstream” vs. “downstream” here, and no UpstreamDeploymentCause—you are listening for deployment of artifacts published earlier in the same build. So the design of the Condition extension point is probably not suitable, unless the range is computed and then tested to see if it is a singleton range consisting of the current build.)

          Thus you might write something like:

          stage 'Build'
          node {
            sh 'make stuff'
            archive 'bin/stuff'
          }
          stage name: 'Stage', concurrency: 1
          input 'Ready to stage?'
          node {
            unarchive 'bin/stuff'
            sh 'scp bin/stuff root@puppethost:/staging' // whatever
          }
          def records = awaitDeployment('staging') // HostRecord[]?
          node {
            sh "run-selenium-tests ${records[0].host}"
          }
          stage name: 'Production', concurrency: 1
          input 'Ready to promote?'
          node {
            unarchive 'bin/stuff'
            sh 'scp bin/stuff root@puppethost:/production' // whatever
          }
          awaitDeployment('production')
          mail to: 'ops@mycorp.com', subject: 'We are live!'
          

          where the input and awaitDeployment steps may pause for long periods.

          Jesse Glick added a comment - Triggering a downstream Workflow job would be useful, but then you are back to job chaining, so you do not get the benefit of having all the logic in one script. What is crucially missing is a way for a Workflow step to pause until it gets a deployment event. You could perhaps cobble this together in a prototype using the generic waitUntil step and calling a couple of Jenkins APIs to inspect current fingerprints looking for DeploymentFacet , though I do not see a way to find these facets efficiently if you do not already have the MD5 checksum of the event, and anyway this would be polling rather than responding immediately. The proper solution is to have a dedicated Workflow step which registers a DeploymentFacetListener that listens for the equivalent of ThresholdCondition but matching the current build. (There is no “upstream” vs. “downstream” here, and no UpstreamDeploymentCause —you are listening for deployment of artifacts published earlier in the same build. So the design of the Condition extension point is probably not suitable, unless the range is computed and then tested to see if it is a singleton range consisting of the current build.) Thus you might write something like: stage 'Build' node { sh 'make stuff' archive 'bin/stuff' } stage name: 'Stage' , concurrency: 1 input 'Ready to stage?' node { unarchive 'bin/stuff' sh 'scp bin/stuff root@puppethost:/staging' // whatever } def records = awaitDeployment( 'staging' ) // HostRecord[]? node { sh "run-selenium-tests ${records[0].host}" } stage name: 'Production' , concurrency: 1 input 'Ready to promote?' node { unarchive 'bin/stuff' sh 'scp bin/stuff root@puppethost:/production' // whatever } awaitDeployment( 'production' ) mail to: 'ops@mycorp.com' , subject: 'We are live!' where the input and awaitDeployment steps may pause for long periods.

          node {
            unarchive 'bin/stuff'
            sh 'scp bin/stuff root@puppethost:/production' // whatever
          }
          awaitDeployment('production')
          

          This proposal splits deployment and wait steps in two separate consecutive instructions, what would happen if the deployment send the finish event notification *before* awaitDeployment started to listen for it?

          Perhaps something like this would be safer:

          awaitDeployment('production') {
            node {
              unarchive 'bin/stuff'
              sh 'scp bin/stuff root@puppethost:/production' // whatever
            }
          }
          

          Antonio Muñiz added a comment - node { unarchive 'bin/stuff' sh 'scp bin/stuff root@puppethost:/production' // whatever } awaitDeployment( 'production' ) This proposal splits deployment and wait steps in two separate consecutive instructions, what would happen if the deployment send the finish event notification * before * awaitDeployment started to listen for it? Perhaps something like this would be safer: awaitDeployment( 'production' ) { node { unarchive 'bin/stuff' sh 'scp bin/stuff root@puppethost:/production' // whatever } }

          Jesse Glick added a comment -

          what would happen if the deployment send the finish event notification before awaitDeployment started to listen for it?

          IIUC Jenkins is already listening for the event notification and so it should have received the event. So the step would need to somehow determine when it starts that the event has already been received. But yes a block-scoped step would probably make this easier to do.

          Jesse Glick added a comment - what would happen if the deployment send the finish event notification before awaitDeployment started to listen for it? IIUC Jenkins is already listening for the event notification and so it should have received the event. So the step would need to somehow determine when it starts that the event has already been received. But yes a block-scoped step would probably make this easier to do.

          Code changed in jenkins
          User: fbelzunc
          Path:
          pom.xml
          src/main/java/org/jenkinsci/plugins/deployment/DeploymentTrigger.java
          http://jenkins-ci.org/commit/deployment-notification-plugin/24c9e56bc0b8ddd8553b5e2023c760f477b1e532
          Log:
          Merge pull request #3 from fbelzunc/JENKINS-28632

          [PARTIALLY FIXED JENKINS-28632] Integration with Workflow to trigger a Workflow Job

          Compare: https://github.com/jenkinsci/deployment-notification-plugin/compare/454a566c95e9...24c9e56bc0b8

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: fbelzunc Path: pom.xml src/main/java/org/jenkinsci/plugins/deployment/DeploymentTrigger.java http://jenkins-ci.org/commit/deployment-notification-plugin/24c9e56bc0b8ddd8553b5e2023c760f477b1e532 Log: Merge pull request #3 from fbelzunc/ JENKINS-28632 [PARTIALLY FIXED JENKINS-28632] Integration with Workflow to trigger a Workflow Job Compare: https://github.com/jenkinsci/deployment-notification-plugin/compare/454a566c95e9...24c9e56bc0b8

          Jesse Glick added a comment -

          For the record what was fixed here was the basic Workflow compatibility (feature parity with freestyle), not the awaitDeployment step which I suppose should be tracked with a separate issue.

          Jesse Glick added a comment - For the record what was fixed here was the basic Workflow compatibility (feature parity with freestyle), not the awaitDeployment step which I suppose should be tracked with a separate issue.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          COMPATIBILITY.md
          http://jenkins-ci.org/commit/workflow-plugin/14acc2b6fa04333fa2d93593bb0ecc617df63446
          Log:
          JENKINS-28632 JENKINS-31749 Noting.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: COMPATIBILITY.md http://jenkins-ci.org/commit/workflow-plugin/14acc2b6fa04333fa2d93593bb0ecc617df63446 Log: JENKINS-28632 JENKINS-31749 Noting.

          Code changed in jenkins
          User: fbelzunc
          Path:
          pom.xml
          src/main/java/org/jenkinsci/plugins/deployment/Condition.java
          src/main/java/org/jenkinsci/plugins/deployment/conditions/ThresholdCondition.java
          src/main/java/org/jenkinsci/plugins/deployment/workflowsteps/AwaitDeploymentAction.java
          src/main/java/org/jenkinsci/plugins/deployment/workflowsteps/AwaitDeploymentStep.java
          src/main/java/org/jenkinsci/plugins/deployment/workflowsteps/AwaitDeploymentStepExecution.java
          src/main/java/org/jenkinsci/plugins/deployment/workflowsteps/WorkflowListenerImpl.java
          http://jenkins-ci.org/commit/deployment-notification-plugin/c572815fb6cac81ba1b566c326a71196bb2bc230
          Log:
          [FIXED JENKINS-28632] Workflow step for awaiting for a deployment

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: fbelzunc Path: pom.xml src/main/java/org/jenkinsci/plugins/deployment/Condition.java src/main/java/org/jenkinsci/plugins/deployment/conditions/ThresholdCondition.java src/main/java/org/jenkinsci/plugins/deployment/workflowsteps/AwaitDeploymentAction.java src/main/java/org/jenkinsci/plugins/deployment/workflowsteps/AwaitDeploymentStep.java src/main/java/org/jenkinsci/plugins/deployment/workflowsteps/AwaitDeploymentStepExecution.java src/main/java/org/jenkinsci/plugins/deployment/workflowsteps/WorkflowListenerImpl.java http://jenkins-ci.org/commit/deployment-notification-plugin/c572815fb6cac81ba1b566c326a71196bb2bc230 Log: [FIXED JENKINS-28632] Workflow step for awaiting for a deployment

          Code changed in jenkins
          User: fbelzunc
          Path:
          pom.xml
          src/main/java/org/jenkinsci/plugins/deployment/conditions/ThresholdCondition.java
          src/main/java/org/jenkinsci/plugins/deployment/workflowsteps/AwaitDeploymentAction.java
          src/main/java/org/jenkinsci/plugins/deployment/workflowsteps/AwaitDeploymentStep.java
          src/main/java/org/jenkinsci/plugins/deployment/workflowsteps/AwaitDeploymentStepExecution.java
          src/main/java/org/jenkinsci/plugins/deployment/workflowsteps/WorkflowListenerImpl.java
          src/main/resources/org/jenkinsci/plugins/deployment/workflowsteps/AwaitDeploymentStep/config.jelly
          src/main/resources/org/jenkinsci/plugins/deployment/workflowsteps/AwaitDeploymentStep/help.html
          http://jenkins-ci.org/commit/deployment-notification-plugin/cc6becf92fcc0f90091f143750f87cb31d93438d
          Log:
          Merge pull request #5 from fbelzunc/JENKINS-28632-clean-example

          [FIXED JENKINS-28632] Workflow step for awaiting for a deployment

          Compare: https://github.com/jenkinsci/deployment-notification-plugin/compare/24c9e56bc0b8...cc6becf92fcc

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: fbelzunc Path: pom.xml src/main/java/org/jenkinsci/plugins/deployment/conditions/ThresholdCondition.java src/main/java/org/jenkinsci/plugins/deployment/workflowsteps/AwaitDeploymentAction.java src/main/java/org/jenkinsci/plugins/deployment/workflowsteps/AwaitDeploymentStep.java src/main/java/org/jenkinsci/plugins/deployment/workflowsteps/AwaitDeploymentStepExecution.java src/main/java/org/jenkinsci/plugins/deployment/workflowsteps/WorkflowListenerImpl.java src/main/resources/org/jenkinsci/plugins/deployment/workflowsteps/AwaitDeploymentStep/config.jelly src/main/resources/org/jenkinsci/plugins/deployment/workflowsteps/AwaitDeploymentStep/help.html http://jenkins-ci.org/commit/deployment-notification-plugin/cc6becf92fcc0f90091f143750f87cb31d93438d Log: Merge pull request #5 from fbelzunc/ JENKINS-28632 -clean-example [FIXED JENKINS-28632] Workflow step for awaiting for a deployment Compare: https://github.com/jenkinsci/deployment-notification-plugin/compare/24c9e56bc0b8...cc6becf92fcc

            fbelzunc Félix Belzunce Arcos
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: