Need some guidance. I am trying to deploy a container in remote server and used groovy script to do this task. I am getting error like below,
[2025-04-02T04:26:43.369Z] + ssh -o StrictHostKeyChecking=no -l ec2-user 13.127.63.170 'docker run -itd -p 80:80 475798544865.dkr.ecr.ap-south-1.amazonaws.com/my-jenkins-project:"${ECR_Tag}"' [2025-04-02T04:26:43.369Z] docker: invalid reference format
Can someone please check and let me know what wrong is there with this command (marked in *) ?
Pipeline stage,
stage ('Docker-deploy-prod') {
steps {
echo "***********************************Starting on remote production server****************************"
sshagent(['Production']) {
sh '''
ssh -o StrictHostKeyChecking=no -l ec2-user 13.127.63.170 'aws ecr get-login-password --region ap-south-1 | sudo docker login --username AWS --password-stdin 475798544865.dkr.ecr.ap-south-1.amazonaws.com'
***ssh -o StrictHostKeyChecking=no -l ec2-user 13.127.63.170 'docker run -itd -p 80:80 475798544865.dkr.ecr.ap-south-1.amazonaws.com/my-jenkins-project:"${ECR_Tag}"'***
'''
}
}
}
aws ecr get-login-password
command is very likely to output the password in theaws
command's default format, which is JSON. Does thedocker login --password-stdin
command expect the password as JSON?${ECR_Tag}
? What happens when you run justecho ${ECR_Tag}
?ssh -o StrictHostKeyChecking=no -l ec2-user 13.127.63.170 'docker run -itd -p 80:80 475798544865.dkr.ecr.ap-south-1.amazonaws.com/my-jenkins-project:latest'
?