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

ansiblePlaybook in pipeline does not create workspace

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • ansible-plugin
    • None
    • ubuntu 20.04
      python 3.10
      java openjdk 11.0.11
      jenkins 2.303.1
      ansible 2.11.3
      all installed on the single ubuntu machine. No additional Nodes.

      When the first stage of a newly created pipeline is ansiblePlaybook the workspace is not created and the pipeline fails immediately with "workspace does not exist"  
      Preceeding this first stage with an arbitrary stage that forces a workspace to be created alleviates this issue. 

      Repro steps
      Create new pipeline with never before used name: I.e. "Pipelineforansiblestage1test" 
      pipeline {
      agent any
      environment

      { win_creds = credentials('jenkinswincreds') }
      stages {
      stage('winrm') {
      steps { ansiblePlaybook( playbook: '/data/ansible/ansiblemaster/winrm_prep.yml', inventory: '$jenkinsrawlist,', extras: '-e \"windows_username=$win_creds_USR windows_password=$win_creds_PSW ansible_username=$win_creds_USR\"') }
      }

      }

      notice that this job fails with error no workspace exists. 

      WORKAROUND:
      pipeline {
      agent any
      environment{ win_creds = credentials('jenkinswincreds') }

      stages {
      stage('Opening Workspace') {
      steps {
      script

      { def date = new Date() def data = "Hello World\nSecond line\n" + date writeFile(file: 'workspacecreated.txt', text: data) sh "ls -l" }

      }
      }
      stage('winrm') {
      steps

      { ansiblePlaybook( playbook: '/data/ansible/ansiblemaster/winrm_prep.yml', inventory: '$jenkinsrawlist,', extras: '-e \"windows_username=$win_creds_USR windows_password=$win_creds_PSW ansible_username=$win_creds_USR\"', installation: "Ansible-2.11.3") }

      }

       

      The above job succeeds as the writefile stage creates a workspace. 

            sirot Jean-Christophe Sirot
            icycler1 john
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: