Use 'input' in a non-blocking way

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Use 'input' in a non-blocking way

foreverman
Hi,

I am trying to setup a cd pipeline with Jenkins recently, and 'input' is used for manual approval  in the pipeline, but it seems that 'input' blocks the executor and won't free the executor util the build is manually approved or cancelled, the pipeline is something like this:

pipeline {
  agent any

  stages {
    stage('build docker container') {
      steps {
        sh 'docker-compose build'
        sh 'docker-compose run start_dependencies'
      }
    }

    stage('prepare database') {
      steps {
        sh 'docker-compose run --rm rails bundle exec rails db:create'
        sh 'docker-compose run --rm rails bundle exec rails db:migrate'
      }
    }

    stage('coding style check') {
      steps {
        sh 'docker-compose run --rm rails bundle exec rubocop'
      }
    }

    stage('automated tests') {
      steps {
        sh 'docker-compose run --rm rails bundle exec rspec'
      }
    }


    stage('deploy to staging') {
      when {
        branch "master"
      }
      
      steps {
        input 'deploy to staging?'
        lock(resource: 'staging-server', inversePrecedence: true) {
          sshagent (credentials: ['a99a855d-e3c8-484c-82ce-f9f6f0fd0ffc']) {
            sh 'docker-compose run -u $(id -u $USER):$(id -g $USER) -v /var/lib/jenkins:/var/lib/jenkins -v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro -v $SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent -e COMMIT=$GIT_COMMIT --rm rails bundle exec mina staging deploy'
          }
        }
      }
    }


  }

  post {
    always {
      sh 'docker-compose kill'
      sh 'docker-compose rm -fv'
    }
  }
}Enter code here...

I tried to pull the 'input' statement out of 'deploy to staging' like this:

stage('approve for deploying to staging') {
  steps {
    input 'deploy to staging?'
  }
}

it still doesn't work, is there a way to use 'input' in a non-blocking way?

Thanks!


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/56c14f9a-879c-4aeb-b9f4-6b636ba7e1f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Use 'input' in a non-blocking way

Victor Martinez
Couple of suggestions:
- https://stackoverflow.com/questions/37831386/jenkins-pipeline-input-step-blocks-executor
- https://stackoverflow.com/questions/42561241/how-to-wait-for-user-input-in-a-declarative-pipeline-without-blocking-a-heavywei


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e37ba9c3-3318-4ee1-9c29-caee0c83cb06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.