`
sillycat
  • 浏览: 2564492 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Jenkins and ECR

 
阅读更多
Jenkins and ECR

First of all, create a repository in the Amazon ECR Repositories
I get a URL as follow
703986672610.dkr.ecr.us-west-2.amazonaws.com/netsuite
Find my AWS security and key, it seems I do not have permission to generate one.
[AWS Management Console] —> [My Security Credentials]
I get my credentials from AWS, in my case the contents are as following
> cat ~/.aws/credentials
[default]
aws_access_key_id = AKIAxxxxxxxxxxx
aws_secret_access_key = B9BQoF5mxxxxxxxxxxxxxxxxxxxx
> cat ~/.aws/config
[default]
region = us-west-2
Here is the steps for install the AWS-cli if you do not have one yet
> sudo apt install python3-pip
> pip3 install awscli --upgrade --user
Test my permissions
> aws ecr get-login --no-include-email
It will generate a login command and I just copy and run that
Then I can list all the repo I have
> aws ecr describe-repositories
On my EC2 machine, I set the .aws then I can list the repositories as well.
Try to build the local Jenkins Docker build ENV for testing
> docker build -f deployment/jenkins/Dockerfile.build -t jenkins-test:1.0 .
Run the building ENV
> docker run -ti --name jenkins-test jenkins-test:1.0 /bin/bash
Remove the application if needed
> docker rm jenkins-test
Some important configuration change to make it working on Jenkins Pipeline
In the Dockerfile.build which prepare the build ENV Docker Image, I add the tool AWS command line
RUN apt-get install -y python3-pip
RUN pip3 install awscli --upgrade --user
RUN ln -s /root/.local/bin/aws /usr/local/bin/aws
I configure the .aws credentials information on the Jenkins machine. I will mapping that to the Docker as well in the pipeline configuration
dockerfile {
    filename 'deployment/jenkins/Dockerfile.build'
       args '-u root:root -v /home/ubuntu/.aws:/root/.aws -v $HOME/.m2:/root/.m2 -v /var/run/docker.sock:/var/run/docker.sock'
}
I am using Docker to start jenkins, so the user is ubuntu on Master, jenkins was starting with root in Docker, then the build ENV is using root as user as well. So there is some permission and users conflicts. I will fix that later.
Here is the Build Process for the Docker
    stage('Build Docker Image') {
      steps {
    sh '''
           docker build -f deployment/docker/Dockerfile -t xxxxxxx.dkr.ecr.us-west-2.amazonaws.com/netsuite:1.5 .
           rm -fr target
       '''
      }
    }
Here is the steps to send to ECR
    stage('Release to ECR') {
      steps {
    sh '''
    $(aws ecr get-login --no-include-email)
    docker push xxxxxxxxx.dkr.ecr.us-west-2.amazonaws.com/netsuite:1.5
       '''
      }
    }

References:
https://docs.aws.amazon.com/AmazonECR/latest/userguide/ECR_AWSCLI.html#AWSCLI_push_image
https://medium.com/@bhadrajatin/ecr-login-from-jenkins-using-pipeline-and-docker-222b696694e0
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html

分享到:
评论

相关推荐

    Jenkins 2: Up and Running

    ### Jenkins 2: Up and Running - 关键知识点详解 #### 一、Jenkins 2 的特点与优势 《Jenkins 2: Up and Running》这本书深入介绍了如何利用Jenkins 2构建灵活、可控且易于维护的持续交付管道。相较于之前的版本...

    Jenkins 2--Up and Running

    Jenkins 2: Up and Running Evolve Your Deployment Pipeline for Next Generation Automation Design, implement, and execute continuous delivery pipelines with a level of flexibility, control, and ease of...

    Jenkins 2 Up and Running.pdf

    设计、实现和执行连续交付管道,在一定程度上灵活、控制和易于维护,这是Jenkins以前不可能做到的。通过这本实用的书,构建管理员、开发人员、测试人员和其他专业人员将了解Jenkins 2中的特性如何将管道定义为代码,...

    jenkins-user-handbook

    If you want to get up and running with Jenkins, see Installing Jenkins for procedures on how to install Jenkins on your supported platform of choice. If you are a typical Jenkins user (of any skill ...

    windows下安装Jenkins 2.289.3 jenkins.msi

    jdk1.8支持的最后一个版本jenkins,验证可用Jenkins Jenkins 2.289.3 jenkins.msi jdk1.8支持的最后一个版本jenkins,验证可用Jenkins Jenkins 2.289.3 jenkins.msi jdk1.8支持的最后一个版本jenkins,验证可用...

    AWS-ECR-with-Terraform:使用Jenkins Pipeline使用Terraform创建ECR

    AWS-ECR-Terraform 使用Jenkins Pipeline使用Terraform创建ECR。

    Jenkins Docker and DevOps The Innovation Catalysts

    Jenkins Docker and DevOps The Innovation Catalysts,Jenkins Docker and DevOps The Innovation Catalysts

    Continuous Delivery with Docker and Jenkins Delivering software at 无水印原版pdf

    Continuous Delivery with Docker and Jenkins Delivering software at scale 英文无水印原版pdf pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自网络,如有...

    jenkins压缩包,jdk8,jenkins.war以及Jenkins安装及配置的pdf

    这个压缩包包含Jenkins的基础环境——JDK8,Jenkins的核心文件——jenkins.war,以及一份关于Jenkins安装和配置的PDF指南,对于学习和部署Jenkins的初学者来说是非常有价值的资源。 首先,我们来详细了解一下...

    Jenkins Essentials.pdf

    Explore continuous integration and automation, along with how to manage and configure Jenkins Discover the process of using Jenkins to build, test, and package Java applications Learn about the ...

    jenkins离线插件安装包大全

    Jenkins是一款广泛使用的开源持续集成工具,用于自动化各种软件开发任务,如构建、测试和部署。在许多情况下,尤其是在企业环境中,Jenkins可能需要在没有互联网连接的“离线”环境中运行。在这种情况下,离线安装...

    Jenkins 2 Up and Running Evolve Your Deployment Pipeline for Next epub

    Jenkins 2 Up and Running Evolve Your Deployment Pipeline for Next Generation Automation 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书

    Continuous Delivery with Docker and Jenkins Delivering software at scale

    [eBook] Continuous Delivery with Docker and Jenkins Delivering software at scale. ISBN: 1787125238, 9781787125230 (2017)

    Continuous Delivery with Docker and Jenkins 无水印英文高清完整.pdf版下载

    Continuous Delivery with Docker and Jenkins 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有...

    Continuous Delivery with Docker and Jenkins epub

    Continuous Delivery with Docker and Jenkins 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

    jenkins老版本资源

    Jenkins 是一款开源的持续集成(Continuous Integration, CI)服务器,它被广泛应用于软件开发过程中,用于自动化构建、测试和部署任务。这个压缩包文件集合提供了 Jenkins 的老版本及其相关资源,这对于那些需要...

    Jenkins持续集成配置

    在“Goals and options”中输入`clean package`,Jenkins会执行`mvn clean package`命令。可以添加特殊参数,比如`-DskipTests=true clean package`来跳过测试。 5. **构建脚本**: - 如果服务器与部署应用在同一...

    jenkins2.328配置连接harbor2.4的认证-jenkinsfile连接harbor-详细文档

    jenkins2.328 配置连接 harbor2.4 的认证-jenkinsfile 连接 harbor—详细文档 jenkins2.328 配置连接 harbor2.4 的认证-jenkinsfile 连接 harbor 是一种常见的 DevOps 实践,将编译构建的镜像推送到 docker-harbor ...

Global site tag (gtag.js) - Google Analytics