@@ -124,29 +124,46 @@ export class InitializeDeploymentService extends BaseService {
124124
125125 const deploymentShortCode = nanoid ( 8 ) ;
126126
127- const [ imageRefError , imageRefResult ] = await tryCatch (
128- getDeploymentImageRef ( {
129- registry : registryConfig ,
130- projectRef : environment . project . externalRef ,
131- nextVersion,
132- environmentType : environment . type ,
133- deploymentShortCode,
134- } )
135- ) ;
127+ // If DEPLOY_IMAGE_OVERRIDE is set, use it instead of generating an image reference
128+ let imageRef : string ;
129+ let isEcr = false ;
130+ let repoCreated = false ;
136131
137- if ( imageRefError ) {
138- logger . error ( "Failed to get deployment image ref" , {
132+ if ( env . DEPLOY_IMAGE_OVERRIDE ) {
133+ imageRef = env . DEPLOY_IMAGE_OVERRIDE ;
134+ logger . info ( "Using image override" , {
135+ imageRef,
139136 environmentId : environment . id ,
140137 projectId : environment . projectId ,
141138 version : nextVersion ,
142- triggeredById : triggeredBy ?. id ,
143- type : payload . type ,
144- cause : imageRefError . message ,
145139 } ) ;
146- throw new ServiceValidationError ( "Failed to get deployment image ref" ) ;
147- }
140+ } else {
141+ const [ imageRefError , imageRefResult ] = await tryCatch (
142+ getDeploymentImageRef ( {
143+ registry : registryConfig ,
144+ projectRef : environment . project . externalRef ,
145+ nextVersion,
146+ environmentType : environment . type ,
147+ deploymentShortCode,
148+ } )
149+ ) ;
148150
149- const { imageRef, isEcr, repoCreated } = imageRefResult ;
151+ if ( imageRefError ) {
152+ logger . error ( "Failed to get deployment image ref" , {
153+ environmentId : environment . id ,
154+ projectId : environment . projectId ,
155+ version : nextVersion ,
156+ triggeredById : triggeredBy ?. id ,
157+ type : payload . type ,
158+ cause : imageRefError . message ,
159+ } ) ;
160+ throw new ServiceValidationError ( "Failed to get deployment image ref" ) ;
161+ }
162+
163+ imageRef = imageRefResult . imageRef ;
164+ isEcr = imageRefResult . isEcr ;
165+ repoCreated = imageRefResult . repoCreated ;
166+ }
150167
151168 // We keep using `BUILDING` as the initial status if not explicitly set
152169 // to avoid changing the behavior for deployments not created in the build server.
0 commit comments