title: how to properly configure jenkins swarm as a service to get proper scrshoots?
body: <p>I have a trouble to find out what is the problem in node setup (centos+gnome+swarm as a service) as it does connect,run gui tests properly but returns "broken" (whole white or "something went wrong) screenshots.</p>
  
  <p>In our CI env, we build and test GUI application (RED - Robot Editor) using Eclipse tool RCPTT which can click on GUI elements to validate functionalities.</p>
  
  <p>Tests are are executed on nodes Centos7 with metacity+gnome+vncserver, whenever something with GUI is wrong (GUI element is not found,validation is not consistant with test criteria), report is created together with screenshot,so tester is able to have a look what has changed in tested app.</p>
  
  <p><strong>When node is manually configured (from Jenkins Nodes configuration page) or swarm script is executed by user on Node (via ssh), screenshots are fine.</strong></p>
  
  <p><strong>When swarm as a service is executed (node is connected, systemctl status  is green,by the same user as run manually), everything is ok besides sreenshots are off (screen res is fine,whole screen is white or with error "Oh no! Something has gone wrong"<a href="https://i.stack.imgur.com/EUywL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EUywL.png" alt="enter image description here"></a>.</strong> </p>
  
  <p>I do not see any error in logs from RCPTT,xvnc,in job console.
  What can be a root cause of broken screenshots?</p>
  
  <p>env setup:
  service definition</p>
  
  <pre><code>[Unit]
  Description=Swarm client to create Jenkins slave
  After=network.target
  After=display-manager.service
  
  [Service]
  ExecStart=&lt;path&gt;/swarm_client.sh start
  ExecStop=&lt;path&gt;/swarm_client.sh stop
  Type=forking
  PIDFile=&lt;path&gt;/slave.pid
  User=root
  Group=root
  
  [Install]
  WantedBy=graphical.target
  </code></pre>
  
  <p>swarm_client.sh</p>
  
  <pre><code>function startclient {
                  PUBIP=`public ip string`
  
          java  \
             -jar ${SWARM_HOME}/swarm-client-3.3.jar \
             -executors 1 \
             -deleteExistingClients \
             -disableClientsUniqueId \
             -fsroot ${CLIENT_HOME} \
             -labels "linux"  \
             -master &lt;jenkins&gt; \
             -name node-Swarm-${PUBIP} 2&gt;&amp;1 &gt; ${CLIENT_HOME}/slave.log &amp;
      PID=$!
          RETCODE=$?
          echo $PID &gt; ${CLIENT_HOME}/slave.pid
          exit $RETCODE
  }
  
  function stopclient {
          if [ -f ${CLIENT_HOME}/slave.pid ];then
                  PID=`head -n1 ${CLIENT_HOME}/slave.pid`
                  kill $PID
                  rm -f ${CLIENT_HOME}/slave.pid
          fi
  }
  SWARM_HOME=&lt;path&gt;/jenkins/swarm
  CLIENT_HOME=&lt;path&gt;/jenkins
  case "$1" in
    start)
          startclient
          ;;
    stop)
          stopclient
          ;;
    *)
          echo "Usage: systemctl {start|stop} swarm_client.service" || true
          exit 1
  esac
  </code></pre>
  
  <p>xvnc logs:</p>
  
  <pre><code>Fri Jul  7 11:05:40 2017
   vncext:      VNC extension running!
   vncext:      Listening for VNC connections on all interface(s), port 5942
   vncext:      created VNC server for screen 0
  gnome-session-is-accelerated: llvmpipe detected.
  </code></pre>