A batch script is a text file containing command-line instructions. In CI, it packages Docker Compose work into a repeatable script that developers can run locally and Jenkins can execute in Windows or Linux containers. section 11.4
A practical CI batch-script workflow is:
- Store the script beside the application, Dockerfiles, and Compose files. section 11.4
- Make the .bat file executable when the pipeline requires it. section 11.4
- Run docker compose with the required files and --pull, then inspect captured build logs. section 11.4
Listing 11.5 Jenkinsfile build step that describes the CI job
# the build stage in the Jenkinsfile- it switches directory, then runs two
# shell commands - the first sets up a script file so it can be executed
# and the second calls the script:
stage('Build') {
steps {
dir('ch11/exercises') {
sh 'chmod +x ./ci/01-build.bat'
sh './ci/01-build.bat'
}
}
}
# and this is what's in 01-build.bat script:
docker compose
-f docker-compose.yml
-f docker-compose-build.yml
build --pull
Use the listing to compare the Jenkins build step with the commands inside 01-build.bat. section 11.4
