Skip to content

Commit

Permalink
Merge pull request #3642 from mercedes-benz/feature-3641-make-client-…
Browse files Browse the repository at this point in the history
…build-reproducible

Feature 3641 make client builds reproducible #3641
  • Loading branch information
sven-dmlr authored Nov 25, 2024
2 parents 847255d + 2072612 commit 7338aea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
18 changes: 10 additions & 8 deletions gradle/build-versioning.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def buildVersionFiles(){
def noStagedChanges = stagedChanges.getAllChanges().isEmpty()
def hasChanged = !noUnstagedChanges || !noStagedChanges
def buildNumber = getBuildNr()
def docsTimeStamp = getLocalBuildNr()
def docsTimeStamp = getTimeStamp()
def currentGitCommit = git.head().abbreviatedId

// ------------------------
Expand Down Expand Up @@ -336,8 +336,8 @@ def buildVersionString(commitTag, boolean hasChanged, buildNumber){
calcversion = calcversion - "-libraries"
calcversion = calcversion - "-pds-tools"
calcversion = calcversion - "-pds"
calcversion = calcversion - "-server"
calcversion = calcversion - "-web-server"
calcversion = calcversion - "-server"
calcversion = calcversion - "-checkmarx-wrapper"
calcversion = calcversion - "-owaspzap-wrapper"
calcversion = calcversion - "-prepare-wrapper"
Expand All @@ -349,29 +349,31 @@ def buildVersionString(commitTag, boolean hasChanged, buildNumber){
if (hasChanged){
calcversion = "${calcversion}-dirty"
}
calcversion = "${calcversion}-${buildNumber}"
if (buildNumber != "") {
calcversion = "${calcversion}-${buildNumber}"
}
return calcversion
}

def getBuildNr(){
if (getServerBuildNr()!=null){
if (getServerBuildNr()!=null) {
return "b"+getServerBuildNr()
}else{
} else {
if (project.hasProperty('sechub.build.timestamp')){
if (project.getProperty('sechub.build.timestamp')=="false"){
return "latest"
}
}
return getLocalBuildNr()
return ""
}
}

def getServerBuildNr(){
return System.getenv('BUILD_NUMBER' )
}

def getLocalBuildNr() {
return new Date().format('yyyyMMddHHmmss')
def getTimeStamp() {
return new Date().format("yyyy-MM-dd HH:mm ('UTC'X)")
}


Expand Down
5 changes: 3 additions & 2 deletions sechub-cli/build_go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ init_go_modules
cd "$SRC_PATH/main"

export CGO_ENABLED=0 # This forces statically linked binaries
GO_LD_FLAGS="-s -w" # strip (reduce size): disable debug symbol table / disable DWARF generation
GO_LD_FLAGS="-s -w -buildid=" # strip (reduce size): disable debug symbol table / disable DWARF generation
GO_COMPILE_FLAGS="-trimpath" # Aim to make builds reproducible

for platform in "${platforms[@]}" ; do
platform_split=(${platform//\// })
Expand All @@ -82,7 +83,7 @@ for platform in "${platforms[@]}" ; do
fi

echo "> building $targetSubFolder"
go build -ldflags="$GO_LD_FLAGS" -o "$buildDir/$output_name" .
go build $GO_COMPILE_FLAGS -ldflags="$GO_LD_FLAGS" -o "$buildDir/$output_name" .
if [ $? -ne 0 ]; then
echo 'Go build failed because of an error'
exit 1
Expand Down

0 comments on commit 7338aea

Please sign in to comment.