@@ -160,7 +160,8 @@ def e2e_test_environment(app_config: ApplicationHarnessConfig, app_domain: str =
160160 env = get_app_environment (app_config , app_domain , False )
161161 return [f"{ k } ={ env [k ]} " for k in env ]
162162
163- def codefresh_app_build_spec (app_name , app_context_path , dockerfile_path = "Dockerfile" , base_name = None , helm_values : HarnessMainConfig = {}, dependencies = None ):
163+ def codefresh_app_build_spec (app_name , app_context_path , dockerfile_path = "Dockerfile" , base_name = None ,
164+ helm_values : HarnessMainConfig = {}, dependencies = None , additional_tags = ()):
164165 logging .info ('Generating build script for ' + app_name )
165166 title = app_name .capitalize ().replace (
166167 '-' , ' ' ).replace ('/' , ' ' ).replace ('.' , ' ' ).strip ()
@@ -172,7 +173,12 @@ def codefresh_app_build_spec(app_name, app_context_path, dockerfile_path="Docker
172173 dockerfile = dockerfile_path )
173174
174175 tag = app_specific_tag_variable (app_name )
175- build ["tag" ] = "${{%s}}" % tag
176+ build ["tags" ] = [
177+ "${{%s}}" % tag ,
178+ "${{DEPLOYMENT_TAG}}-dev" ,
179+ "${{CF_BRANCH_TAG_NORMALIZED_LOWER_CASE}}" ,
180+ * additional_tags ,
181+ ]
176182
177183 specific_build_template_path = join (app_context_path , 'build.yaml' )
178184 if exists (specific_build_template_path ):
@@ -187,7 +193,7 @@ def codefresh_app_build_spec(app_name, app_context_path, dockerfile_path="Docker
187193 build ['dependencies' ] = dependencies
188194
189195 def get_other_image_name (app_name ):
190- return ("${{REGISTRY}}/" + f"{ build_steps [app_name ]['image_name' ]} :{ build_steps [app_name ]['tag' ]} " )\
196+ return ("${{REGISTRY}}/" + f"{ build_steps [app_name ]['image_name' ]} :{ build_steps [app_name ]['tags' ][ 0 ]} " )\
191197 if app_name in build_steps \
192198 else image_tag_with_variables (app_name , app_specific_tag_variable (app_name ), base_name )
193199
@@ -252,7 +258,8 @@ def codefresh_steps_from_base_path(base_path, fixed_context=None, include=build_
252258 "Dockerfile" ),
253259 base_name = base_name ,
254260 helm_values = helm_values ,
255- dependencies = dependencies
261+ dependencies = dependencies ,
262+ additional_tags = ('latest' ,) if not publish else ()
256263 )
257264
258265 build_steps [app_name ] = build
@@ -263,7 +270,7 @@ def codefresh_steps_from_base_path(base_path, fixed_context=None, include=build_
263270 steps [CD_STEP_PUBLISH ]['steps' ] = {}
264271 steps [CD_STEP_PUBLISH ]['steps' ]['publish_' + app_name ] = codefresh_app_publish_spec (
265272 app_name = app_name ,
266- build_tag = build and build ['tag' ],
273+ build_tag = build and build ['tags' ][ 0 ],
267274 base_name = base_name
268275 )
269276 found = True
@@ -474,9 +481,7 @@ def codefresh_app_publish_spec(app_name, build_tag, base_name=None):
474481 app_name , base_name ), build_tag or '${{DEPLOYMENT_TAG}}' ),
475482 title = title ,
476483 )
477- if not build_tag :
478- # if not build tag we are reusing old images and deploying on a production env
479- step_spec ['tags' ].append ('latest' )
484+ step_spec ['tags' ].append ('latest' )
480485 return step_spec
481486
482487
0 commit comments