Skip to content

Commit

Permalink
Merge pull request #10 in M8A/github-views from ~I15784/github-views:…
Browse files Browse the repository at this point in the history
…feature/read-versionfile-for-tagging to develop

* commit '75953ad4eebc25513fc7f71c51b0310d4b9c6abf':
  MCU8QA-274 Read version from VERSION.js
  • Loading branch information
alexmchp committed Sep 16, 2020
2 parents 1dcdf14 + 75953ad commit 33e4c6e
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions Jenkinsfilek8s
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import java.time.format.DateTimeFormatter

def now = LocalDateTime.now()



def artifactoryURL = "artifacts.microchip.com:7999/microchip"
def dockerRepoPath = "default"
def dockerImages = ["backend", "frontend"]
Expand All @@ -18,7 +16,10 @@ pipeline {
label 'agent-build'
yamlFile 'CI/k8s.yml'
}
}
}
environment {
VESION_PATTERN = '\\d+\\.\\d+\\.\\d+'
}
options {
timestamps ()
timeout(time: 20, unit: 'MINUTES')
Expand Down Expand Up @@ -56,7 +57,9 @@ pipeline {
for (String item : dockerImages) {
echo "running in script()"
dockerImage = item
dockerImageRegistryPath = "$artifactoryURL/$dockerRepoPath/$dockerImage"
dockerImageRegistryPath = "$artifactoryURL/$dockerRepoPath/$dockerImage"
dockerVersion = getVersion(dockerImage)

echo """
Using these variables
artifactoryURL: $artifactoryURL
Expand Down Expand Up @@ -95,6 +98,8 @@ pipeline {
echo "running in script()"
dockerImage = item
dockerImageRegistryPath = "$artifactoryURL/$dockerRepoPath/$dockerImage"
dockerVersion = getVersion(dockerImage)

echo """
Building $dockerImage
The current WORKSPACE is: ${WORKSPACE}
Expand Down Expand Up @@ -128,6 +133,8 @@ pipeline {
echo "running in script()"
dockerImage = item
dockerImageRegistryPath = "$artifactoryURL/$dockerRepoPath/$dockerImage"
dockerVersion = getVersion(dockerImage)

echo """
Building $dockerImage
The current WORKSPACE is: ${WORKSPACE}
Expand All @@ -140,6 +147,7 @@ pipeline {
/kaniko/executor \
--context ${WORKSPACE}/${dockerImage} \
--dockerfile Dockerfile \
--destination=$dockerImageRegistryPath:latest \
--destination=$dockerImageRegistryPath:prod \
--destination=$dockerImageRegistryPath:$dockerVersion \
--destination=$dockerImageRegistryPath:$BRANCH_NAME
Expand All @@ -152,4 +160,16 @@ pipeline {
}
}
}
}

def getVersion(String dockerImage) {
def versionFile = findFiles(glob: "${dockerImage}/**/VERSION.js")
def version = 'latest'
def versionString = null
for(String file : versionFile) {
versionString = readFile "${file}"
def versionList = (versionString =~ "$VESION_PATTERN")
version = versionList ? versionList[0]:'latest'
}
return version
}

0 comments on commit 33e4c6e

Please sign in to comment.