Script to archive and deploy to source control with Mercurial
Specify the location of the repository to be cloned using <REPOSITORY_PATH>.
rmdir /S /Q repo_name hg clone -u tip "<REPOSITORY_PATH>" repo_name del /Q "repo_name\${JobName}\${TargetName}.zip" mkdir "repo_name\${JobName} winrar a "repo_name\${JobName}\${TargetName}.zip" -ep1 -r "${DeployFolder}\*" cd repo_name hg addremove hg commit -m "Scheduled update from job: '${JobName}', target: '${TargetName}'." hg push
Script steps explained:
- Remove any previously existing subdirectory named "repo_name" in the folder of the current job.
Mercurial makes a copy of the repository at the path given at <REPOSITORY_PATH>.
- Delete the .zip file at the given path, should it exist.
- Make a new directory to place the archived file in.
- Instruct an archiving tool to create an archived file inside the newly created folder.
- Step inside the "repo_name" folder.
- Changes are compared between the local repository and the online repository. New files are added to the commit and missing files are removed.
- A commit is made to the online repository and a message is written for the commit.
- The committed files are pushed to the online repository.