[JIRA] (JENKINS-48379) Input/parameters for Stages

3 views
Skip to first unread message

rmpestano@gmail.com (JIRA)

unread,
Mar 26, 2018, 9:18:02 AM3/26/18
to jenkinsc...@googlegroups.com
Rafael Pestano updated an issue
 
Jenkins / New Feature JENKINS-48379
Input/parameters for Stages
Change By: Rafael Pestano
Attachment: agent-blocked.png
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

rmpestano@gmail.com (JIRA)

unread,
Mar 26, 2018, 9:19:01 AM3/26/18
to jenkinsc...@googlegroups.com
Rafael Pestano commented on New Feature JENKINS-48379
 
Re: Input/parameters for Stages

Hi guys, I'm using pipeline decçarative (and pipeline model api) v1.2.7 and am using the input directive on a stage like below:

pipeline { 
    agent any
    tools { 
        maven 'Maven 3.3.9' 
        jdk 'jdk1.8' 
    }
    
    stages {    
        stage("Build") {
            steps {
                sh 'mvn clean package'
            }
        }  
        
        stage("Ir para produção?") {
            input {
                message "Aprovar o deploy?"
                ok "Sim"
            }
            agent {
                label 'master'
            }
            steps {
                deploy ambiente: 'DES-7.0', grupo: 'APM'
            }
        }
        
    
   }//fim stages  
}  

but a Jenkins executor is being alocated. I thought this issue would fix this.

IOn image "agent-blocked.png" attached you can see a job queued (waiting for executor) and one executing the pipeline above (waiting for manual approval).

Jenkins v2.89.3
Pipeline declarative v1.2.7

rmpestano@gmail.com (JIRA)

unread,
Mar 26, 2018, 9:20:02 AM3/26/18
to jenkinsc...@googlegroups.com
Hi guys, I'm using pipeline decçarative (and pipeline model api) v1.2.7 and am using the input directive on a stage like below:
{noformat}

pipeline {
    agent any
    tools {
        maven 'Maven 3.3.9'
        jdk 'jdk1.8'
    }
    
    stages {    
        stage("Build") {
            steps {
                sh 'mvn clean package'
            }
        }  
        
        stage("Ir para produção?") {
            input {
                message "Aprovar o deploy?"
                ok "Sim"
            }
            agent {
                label 'master'
            }
            steps {
                deploy ambiente: 'DES-7.0', grupo: 'APM'
            }
        }
        
    
   }//fim stages  
}  {noformat}


but a Jenkins executor is being alocated. I thought this issue would fix this.

IOn In image "agent-blocked.png" attached you can see a job queued (waiting for executor) and one executing the pipeline above (waiting for manual approval).
!agent-blocked.png|thumbnail!

Jenkins v2.89.3
Pipeline declarative v1.2.7

rmpestano@gmail.com (JIRA)

unread,
Mar 26, 2018, 9:28:02 AM3/26/18
to jenkinsc...@googlegroups.com
Rafael Pestano commented on New Feature JENKINS-48379
 
Re: Input/parameters for Stages

Alright, got it working, the pipeline must run with agent 'none' and then each stage must declare it's agent:

pipeline { 
    agent none
    tools { 
        maven 'Maven 3.3.9' 
        jdk 'jdk1.8' 
    }
    
    stages {            
        stage("Build") {
             agent {
                label 'master'
            }
            steps {
                sh 'mvn clean package'
            }
        }  
        stage("Ir para produção?") {
            input {
                message "Aprovar o deploy?"
                ok "Sim"
            }
            agent {
                label 'master'
            }
            steps {
              deploy ambiente: 'DES-7.0', grupo: 'APM' 
            }
        }
        
    
   }//fim stages  
}  

rmpestano@gmail.com (JIRA)

unread,
Mar 26, 2018, 9:35:02 AM3/26/18
to jenkinsc...@googlegroups.com
Alright, got it working, the pipeline must run with agent 'none' and then each stage must declare it's agent:


{noformat}
pipeline {
    agent none
//important
    tools {
        maven 'Maven 3.3.9'
        jdk 'jdk1.8'
    }
    
    stages {            
        stage("Build") {
             agent { any
                label 'master'
            }
            steps {
                sh 'mvn clean package'
            }
        }  
        stage("Ir para produção?") {
            input {
                message "Aprovar o deploy?"
                ok "Sim"
            }
            agent {   any //must be declared after input directive
                label 'master'
            }
            steps {
              deploy ambiente: 'DES-7.0', grupo: 'APM'
            }
        }
        
    
           
   }// fim end stages  
}  
{noformat}

rmpestano@gmail.com (JIRA)

unread,
Mar 26, 2018, 9:36:02 AM3/26/18
to jenkinsc...@googlegroups.com
Rafael Pestano edited a comment on New Feature JENKINS-48379
Alright, got it working, the pipeline must run with agent 'none' and then each stage must declare it's agent:

{noformat}
pipeline {
    agent none //important
    tools {
        maven 'Maven 3.3.9'
        jdk 'jdk1.8'
    }
    
    stages {            
        stage("Build") {
             agent any
            steps {
                sh 'mvn clean package'
            }
        }  
        stage("Ir para produção?") {
            input {
                message "Aprovar o deploy?"
                ok "Sim"
            }
            agent  any //must be declared after input directive
            steps {
              deploy ambiente: 'DES-7.0', grupo: 'APM'
            }
        }
           
   }//end stages  
}  
{noformat}

torsten.kleiber@ikb.de (JIRA)

unread,
Apr 11, 2018, 6:47:03 AM4/11/18
to jenkinsc...@googlegroups.com
Torsten Kleiber commented on New Feature JENKINS-48379
 
Re: Input/parameters for Stages

But when I need a timeout around the input step, the executor is blocked again.

My requirement is, that when a deployment is not proceeded in a defined time, the the pipeline has to be cancelled.

torsten.kleiber@ikb.de (JIRA)

unread,
Apr 11, 2018, 7:33:02 AM4/11/18
to jenkinsc...@googlegroups.com
Torsten Kleiber edited a comment on New Feature JENKINS-48379
 
Re: Input/parameters for Stages
But when I need a timeout around the input step, I must use this inside step and the executor is blocked again. So we need timeout too in stage.

My requirement is, that when a deployment is not proceeded in a defined time, the the pipeline has to be cancelled.

rmpestano@gmail.com (JIRA)

unread,
Apr 11, 2018, 7:37:02 AM4/11/18
to jenkinsc...@googlegroups.com
Rafael Pestano commented on New Feature JENKINS-48379
 
Re: Input/parameters for Stages

Hi Torsten Kleiber,

I haven't tried but last version of declarative pipeline (1.2.8) states it supports input and timeout outside steps, see here: https://jenkins.io/blog/2018/04/09/whats-in-declarative/

Lastly, you can use timeout in the stage options, as mentioned above, to time-out the input if too much time has passed without a response.

torsten.kleiber@ikb.de (JIRA)

unread,
Apr 11, 2018, 8:19:03 AM4/11/18
to jenkinsc...@googlegroups.com
Torsten Kleiber commented on New Feature JENKINS-48379
 
Re: Input/parameters for Stages

Thanks I have bookmarked this, but not read before. Stage timeouts seems what I need!

rmpestano@gmail.com (JIRA)

unread,
Apr 11, 2018, 10:09:12 AM4/11/18
to jenkinsc...@googlegroups.com
Rafael Pestano commented on New Feature JENKINS-48379
 
Re: Input/parameters for Stages

Just tested and is working great:

pipeline {

 agent none

 stages {

    stage("deploy to production ") {
            options {
                timeout(time: 1, unit: 'DAYS')
            }
            input {
                message "Approve deploy?"
                ok "Yes"
            }
            agent  any //must be declared after input directive
            steps {
              deploy env: 'PRODUCTION' 
            }
        }

   }//end stages

   post {
        always {
             node('master') { //important because the pipeline agent is none and some plugins may need to access the workspace
                 lastChanges()
             }
        }
    }  

} //end pipeline

mneale@cloudbees.com (JIRA)

unread,
Apr 11, 2018, 7:26:02 PM4/11/18
to jenkinsc...@googlegroups.com
Michael Neale commented on New Feature JENKINS-48379
 
Re: Input/parameters for Stages

nice - Torsten Kleiber should add this to docs!

torsten.kleiber@ikb.de (JIRA)

unread,
Apr 12, 2018, 1:05:02 AM4/12/18
to jenkinsc...@googlegroups.com
Torsten Kleiber commented on New Feature JENKINS-48379
 
Re: Input/parameters for Stages

Don't understand - what do you mean by this?

mneale@cloudbees.com (JIRA)

unread,
Apr 12, 2018, 4:28:02 AM4/12/18
to jenkinsc...@googlegroups.com
Michael Neale commented on New Feature JENKINS-48379
 
Re: Input/parameters for Stages

Torsten Kleiber oh just mean that the docs website would ideally cover this feature (if it doesn't already) - nothing more than that. 

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:25:26 PM10/22/19
to jenkinsc...@googlegroups.com
Liam Newman closed an issue as Fixed
 

Bulk closing resolved issues.

Change By: Liam Newman
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages