Skip to content

Commit 4a15b2d

Browse files
committed
fix(jenkins): fix docker build command and cd into the root folder if applicable
1 parent 55776da commit 4a15b2d

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

infra/jenkins/jenkins.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ unclassified:
2828
security:
2929
scriptApproval:
3030
approvedScriptHashes:
31-
- "SHA512:4221429e203439d7010910774f0ef107c56e054eb7001881a02852d108c03fb8d8470c15e2a6d27141b604075db9c09223a7e5c083478dcef770f84b733ceb2a"
31+
- "SHA512:eb6ddc115541e8f2c7d8459abbfc8dc262d6d6b711371a2764e05ce9492ca18c50002afe65635480dbc0509c0d8acaf8ba73d42450fe518816d3b45fd79d9088"
3232
forceSandbox: false

infra/jenkins/project_job.groovy

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
def String projectName = binding.variables['PROJECT_NAME']
22
def String gitUrl = binding.variables['GIT_URL']
33
def String gitBranch = binding.variables['GIT_BRANCH']
4+
def String root_folder = binding.variables['ROOT_FOLDER']
45
def String credentialsId = binding.variables['GIT_CREDENTIALS_ID']
56
def File languageFile = new File("${WORKSPACE}/repo/detected_language.txt")
67
def String language = languageFile.text.trim().toLowerCase()
@@ -33,16 +34,14 @@ freeStyleJob("Projects/${projectName}") {
3334

3435
steps {
3536
shell("echo Building ${projectName} using ${baseImage}")
36-
shell("docker build -t ${projectName}:${language} --build-arg BASE_IMAGE=${baseImage} .")
3737
shell("""
38-
#!/bin/bash
39-
set -e
40-
// if [ -f whanos.yml ]; then
41-
// echo "Deploying ${projectName} to Kubernetes..."
42-
// kubectl apply -f whanos.yml
43-
// else
44-
// echo "No whanos.yml found, skipping deployment."
45-
// fi
38+
cd /var/jenkins_home/workspace/Projects/${projectName}/${root_folder}
39+
if [ -f Dockerfile ]; then
40+
echo "Dockerfile found, building image..."
41+
docker build -t ${projectName} --build-arg BASE_IMAGE=${baseImage} .
42+
else
43+
docker build -t ${projectName} -f /images/${language}/Dockerfile.standalone .
44+
fi
4645
""")
4746
}
4847
}

0 commit comments

Comments
 (0)