About me● Since January 2017 working @ GN
● Driving CI and CD in embedded software development
● Software Craftsman
● CI / CD Enthusiast
● Speaker and author
# Maven builddocker run -it --rm \
-v "$PWD":/usr/src/myproject \-w /usr/src/myproject \maven:3-jdk-9 mvn clean install
# Gradle builddocker run -it --rm \
-v "$PWD":/usr/src/myproject \-w /usr/src/myproject \openjdk-8-jdk ./gradlew clean build
When to use?● Most tools provided by package
manager
● Seldom changes to the tool chain
● Local builds
Advantages● No modifications to the build script
● Easy to restore build environments for old versions
● Test new version of the tools
pipeline {agent nonestages {
stage('Build') {agent {
docker ‘java:8-jdk'}steps {
sh './gradlew clean build'}
}}
}
To consider● CI pipeline glues together the build steps
○ How to deal with local builds?
○ Alternative: Make single steps accessible from build script
● Can speed up the builds by providing enough computing power on the build server
task genThumbnails(type:Exec) {commandLine "docker run -it --rm -v ${rootDir}:${ws} -w ${ws} " +
"python:2.7 python genThumbnails.py"}
> ./gradlew genThumbnails
tasks.addRule("Pattern: docker<TaskName>: docker") { String taskName ->if (taskName.startsWith("docker")) {
def taskNameToCall = (taskName - 'docker').toLowerCase()def taskToCall = tasks.findByName(taskNameToCall)if (taskToCall && taskToCall instanceof Exec) {def cmd = ['docker', 'run', '--rm', '-v', "${taskToCall.workingDir.name}:${ws}",
'-w', "${ws}", 'python:2.7']cmd.addAll(taskToCall.commandLine)
task(taskName, type: Exec, {commandLine cmd
})}}}
> ./gradlew dockerGenthumbnails
Advantages● Higher modularity
● Testing new versions of a tool is easy
● Higher reuse of existing images
FROM microsoft/windowsservercore
ENV url https://www.python.org/ftp/python/2.7.14/python-2.7.14.amd64.msi
RUN $MsiFile = $env:Temp + '\ipython.msi' ; \(New-Object Net.WebClient).DownloadFile($url, $MsiFile) ; \Start-Process msiexec.exe -ArgumentList '/i', $MsiFile, '/quiet', '/norestart',
'/jm' -NoNewWindow -Wait
Installing an MSI… if it supports silent install
[email protected]/profile/Tobias_Getrostwww.linkedin.com/in/tobias-getrosthttps://github.com/getrosttgetrost.org
Tobias Getrost
Recommended