diff --git a/Jenkinsfile b/Jenkinsfile index 1343ac1ab6caf..67d90d023c8bd 100755 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -234,19 +234,57 @@ def build_image(image_name) { def full_name = "${image_name}:${env.BRANCH_NAME}-${hash}" sh( script: "${docker_build} ${image_name} --spec ${full_name}", - label: 'Building docker image' + label: 'Build docker image' ) + aws_account_id = sh( + returnStdout: true, + script: 'aws sts get-caller-identity | grep Account | cut -f4 -d\\"', + label: 'Get AWS ID' + ).trim() + + try { + // Use a credential so Jenkins knows to scrub the AWS account ID which is nice + // (but so we don't have to rely it being hardcoded in Jenkins) + withCredentials([string( + credentialsId: 'aws-account-id', + variable: '_ACCOUNT_ID_DO_NOT_USE', + )]) { + withEnv([ + "AWS_ACCOUNT_ID=${aws_account_id}", + 'AWS_DEFAULT_REGION=us-west-2']) { + sh( + script: ''' + set -x + aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com + ''', + label: 'Log in to ECR' + ) + sh( + script: """ + set -x + docker tag ${full_name} \$AWS_ACCOUNT_ID.dkr.ecr.\$AWS_DEFAULT_REGION.amazonaws.com/${full_name} + docker push \$AWS_ACCOUNT_ID.dkr.ecr.\$AWS_DEFAULT_REGION.amazonaws.com/${full_name} + """, + label: 'Upload image to ECR' + ) + } + } + } finally { + sh( + script: 'rm -f ~/.docker/config.json', + label: 'Clean up login credentials' + ) + } sh( script: "docker rmi ${full_name}", - label: 'Removing docker image' + label: 'Remove docker image' ) sh "echo NYI: Uploading docker image to registry..." } if (rebuild_docker_images) { stage('Docker Image Build') { - // TODO in a follow up PR: Upload to ECR, find tag and use in - // subsequent builds + // TODO in a follow up PR: Find ecr tag and use in subsequent builds parallel 'ci-lint': { node('CPU') { timeout(time: max_time, unit: 'MINUTES') { diff --git a/docker/Dockerfile.ci_lint b/docker/Dockerfile.ci_lint index 472becb73d05e..b13664ce38c05 100644 --- a/docker/Dockerfile.ci_lint +++ b/docker/Dockerfile.ci_lint @@ -24,36 +24,36 @@ RUN apt-get update --fix-missing RUN apt-get update && apt-get install -y wget git sudo make -COPY install/ubuntu1804_install_python.sh /install/ubuntu1804_install_python.sh -RUN bash /install/ubuntu1804_install_python.sh +# COPY install/ubuntu1804_install_python.sh /install/ubuntu1804_install_python.sh +# RUN bash /install/ubuntu1804_install_python.sh -# Globally disable pip cache -RUN pip config set global.no-cache-dir false +# # Globally disable pip cache +# RUN pip config set global.no-cache-dir false -RUN apt-get update && apt-get install -y doxygen graphviz curl shellcheck +# RUN apt-get update && apt-get install -y doxygen graphviz curl shellcheck -RUN pip3 install cpplint pylint==2.4.4 mypy==0.902 black==20.8b1 flake8==3.9.2 +# RUN pip3 install cpplint pylint==2.4.4 mypy==0.902 black==20.8b1 flake8==3.9.2 -# Rust env (build early; takes a while) -COPY install/ubuntu_install_rust.sh /install/ubuntu_install_rust.sh -RUN bash /install/ubuntu_install_rust.sh -ENV RUSTUP_HOME /opt/rust -ENV CARGO_HOME /opt/rust -ENV PATH $PATH:$CARGO_HOME/bin +# # Rust env (build early; takes a while) +# COPY install/ubuntu_install_rust.sh /install/ubuntu_install_rust.sh +# RUN bash /install/ubuntu_install_rust.sh +# ENV RUSTUP_HOME /opt/rust +# ENV CARGO_HOME /opt/rust +# ENV PATH $PATH:$CARGO_HOME/bin -# java deps for rat -COPY install/ubuntu_install_java.sh /install/ubuntu_install_java.sh -RUN bash /install/ubuntu_install_java.sh +# # java deps for rat +# COPY install/ubuntu_install_java.sh /install/ubuntu_install_java.sh +# RUN bash /install/ubuntu_install_java.sh -COPY install/ubuntu_install_rat.sh /install/ubuntu_install_rat.sh -RUN bash /install/ubuntu_install_rat.sh +# COPY install/ubuntu_install_rat.sh /install/ubuntu_install_rat.sh +# RUN bash /install/ubuntu_install_rat.sh -COPY install/ubuntu1804_install_clang_format.sh /install/ubuntu1804_install_clang_format.sh -RUN bash /install/ubuntu1804_install_clang_format.sh +# COPY install/ubuntu1804_install_clang_format.sh /install/ubuntu1804_install_clang_format.sh +# RUN bash /install/ubuntu1804_install_clang_format.sh -COPY install/ubuntu_install_nodejs.sh /install/ubuntu_install_nodejs.sh -RUN bash /install/ubuntu_install_nodejs.sh +# COPY install/ubuntu_install_nodejs.sh /install/ubuntu_install_nodejs.sh +# RUN bash /install/ubuntu_install_nodejs.sh -# To prevent `black` command line errors caused by ASCII encoding -ENV LC_ALL=C.UTF-8 -ENV LANG=C.UTF-8 +# # To prevent `black` command line errors caused by ASCII encoding +# ENV LC_ALL=C.UTF-8 +# ENV LANG=C.UTF-8