简体   繁体   中英

In Jenkins - Windows Batch Command Not Working

I am trying to execute a window batch command in Jenkins, and it is not working. I have reviewed Run batch command in jenkins , but I couldn't fix from that post.

I ran the following command to copy a file to a new location and give it a new name:

copy /B "%my_home%\base\dist\proj*.war" "%my_home%\base\dist\wars\proj.war"

In my case, the source directory has a single file called proj123.war. The file is successfully copied the the target directory, but the name remains proj123.war rather than renaming to proj.war.

Any idea what I might be doing wrong? Thanks for any help!

For 1) Your statement doesn't make any sense.

copy /B "%my_home%\\base\\dist\\proj*.war" "%my_home%\\base\\dist\\wars\\proj*.war"

Say you have

projA.war projB.war projC.war

They will all get saved as proj.war , first A, then B, then C. So it will be over written. They won't get copied as individual files.

You also don't need the /B .

In the future, provide a detailed description of the error you're getting.

EDIT: Given the update the comment, the desired command would be.

copy /B "%my_home%\\base\\dist\\proj*.war" "%my_home%\\base\\dist\\wars"

This will copy all files that match proj*.war to the wars directory while keeping the original names.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM