我正在Ubuntu AMI上运行我的奴隶,这些奴隶已经预安装了docker。我正在尝试从DockerFile在从属服务器上构建一个Docker容器并将其推送到ECR存储库。
我因为这失败而感到困惑,但是我不明白为什么失败。
node('cicd_ec2') {
try {
stage('Prepare Environment'){
// slackSend color: 'good', message: "Job: ${currentBuild.fullDisplayName} was started \n ${env.BUILD_URL}"
cleanWs()
checkout scm
}
stage('Docker build'){
docker.build('jenkins')
}
stage('Docker Push'){
docker.withDockerRegistry(credentialsId: 'ecr:us-east-1:jenkins_cicd', url: 'https://1account-number.dkr.ecr.us-east-1.amazonaws.com') {
docker.image('jenkins').push('latest')
}
}
}
catch (err) {
currentBuild.result = 'FAILURE'
// slackSend color: 'danger', message: "Job: ${currentBuild.fullDisplayName} Result Was *ERROR* \n ${env.BUILD_URL}"
}
finally {
if ( currentBuild.result == null || currentBuild.result == 'SUCCESS' ) {
// slackSend color: "good", message: "Job: ${currentBuild.fullDisplayName} Result Was *SUCCESS* \n ${env.BUILD_URL}"
}
else if( currentBuild.result == "FAILURE" ) {
slackSend color: "danger", message: "Job: ${currentBuild.fullDisplayName} Result Was *FAILURE* \n ${env.BUILD_URL}"
}
else if( currentBuild.result == "UNSTABLE" ) {
slackSend color: "warning", message: "Job: ${currentBuild.fullDisplayName} Result Was *UNSTABLE* \n ${env.BUILD_URL}"
}
else {
slackSend color: "danger", message: "Job: ${currentBuild.fullDisplayName} Result Was *UNCLEAR* \n ${env.BUILD_URL}"
}
}
}
在这里登录: