0
bat 'set OutputFolderName=%date:~12,2%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%'
bat 'mkdir %OutputFolderName%'

These two commands should give the correct output but they aren't working. This is the error I got:

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Will
  • 3
  • 3

1 Answers1

0

Try multiline bat command as follows:

bat """
    set OutputFolderName=%date:~12,2%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%
    mkdir %OutputFolderName%
"""

Edit: Updated with snapshots

Have a look at my pipeline snapshot here: Pipeline Snapshot

Pipeline Console Output Pipeline Console Output

Creates a folder something like this:

Workspace Snapshot

Siddharth Kaul
  • 871
  • 10
  • 20
  • Nope Still not working...What's surprising is these commands work perfectly in a jenkinsjob but not in a pipeline script – Will Jul 30 '21 at 03:55
  • I updated the answer with snapshot showing how the pipeline command I replaced with your command and it works. Does your Jenkins Service or Agent has permission to created folders in the workspace?? – Siddharth Kaul Jul 30 '21 at 08:32
  • Thanks a lot!!! I made a mistake earlier in multiline bat command...(kept 3 double quotes instead of 3 single quotes) I changed that and Now its working fine – Will Jul 30 '21 at 13:40