Simulate user input in Jenkins Python script

Source: Internet
Author: User

Simulate user input in Jenkins Python script

This requirement is rare, but it is difficult to test successfully, so we need to record it.

We use Jenkins + TexturePacker to automatically package and convert resources.

To run TexturePacker for the first time, enter agree in the command line to confirm the copyright. The Jenkins system environment is independent from the desktop system, so you have to enter agree again in Jenkins. So there is a very disgusting situation. The command line running TexturePacker in Jenkins does not input agree to the user.

Fortunately, there are omnipotent python scripts. It can simulate user input. In this way, you only need to Execute this script in Jenkins (create a Job and run the following script in Execute Shell)

#! Python.exe import subprocesshils = subprocess. popen ([r 'd: \ Workspace \ TexturePacker \ bin \ TexturePacker.exe '], stdin = subprocess. PIPE, stdout = subprocess. PIPE) result = Hils. communicate (input = r 'agree ') [0] print Hils. returncodeprint Hils. communicate ()


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.