Created
April 2, 2022 07:53
-
-
Save subudear/b70e1c60ca2b5d6698b3d454d3893812 to your computer and use it in GitHub Desktop.
jfrog to aws ecr image transfer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trigger: | |
| - main | |
| variables: | |
| - group: artifactory | |
| - group: AWS | |
| jobs: | |
| - job: OnBuildHost | |
| pool: | |
| name: Self-Hosted-Agent | |
| steps: | |
| - task: Docker@2 | |
| #condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) | |
| displayName: 'Docker Build' | |
| inputs: | |
| containerRegistry: '$(artifactoryRegistryServiceConnection)' | |
| repository: '$(imageRepository)' | |
| command: 'build' | |
| Dockerfile: '$(dockerfilePath)' | |
| tags: '$(Build.BuildNumber)' | |
| - task: ArtifactoryToolsInstaller@1 | |
| displayName: "Install JFrog CLI" | |
| inputs: | |
| artifactoryService: 'BasicAuth-artifactory' | |
| cliInstallationRepo: 'https://releases.jfrog.io/ui/native/jfrog-cli/v2/' | |
| - task: ArtifactoryDocker@1 | |
| displayName: "Push image to Artifactory" | |
| #condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) | |
| inputs: | |
| command: 'push' | |
| artifactoryService: '$(artifactoryServiceConnection)' | |
| targetRepo: '$(targetRepo)' | |
| imageName: '$(imageName):$(imageTag)' | |
| - task: ArtifactoryDocker@1 | |
| displayName: "Pull image from Artifactory" | |
| inputs: | |
| command: 'pull' | |
| artifactoryService: '$(artifactoryServiceConnection)' | |
| sourceRepo: '$(sourceRepo)' | |
| imageName: '$(imageName):$(imageTag)' | |
| - task: CmdLine@2 | |
| displayName: "Tag image for Azure Registry" | |
| inputs: | |
| script: | | |
| echo Tagging the image | |
| docker tag subudear.jfrog.io/helloworldrepo-docker/helloworld:$(Build.BuildNumber) $(AWS_ECR_MAGE_URI):$(Build.BuildNumber) | |
| - task: ECRPushImage@1 | |
| displayName: "Push image (Buildnumber) to AWS ECR" | |
| inputs: | |
| awsCredentials: 'AWS_Service' | |
| regionName: $(AWS_REGION) | |
| imageSource: 'imagename' | |
| sourceImageName: $(AWS_ECR_MAGE_URI) | |
| sourceImageTag: $(Build.BuildNumber) | |
| pushTag: $(Build.BuildNumber) | |
| repositoryName: $(AWS_ECR_REPOSITORY_NAME) | |
| - task: ECRPushImage@1 | |
| displayName: "Push image (latest) to AWS ECR" | |
| inputs: | |
| awsCredentials: 'AWS_Service' | |
| regionName: $(AWS_REGION) | |
| imageSource: 'imagename' | |
| sourceImageName: $(AWS_ECR_MAGE_URI) | |
| sourceImageTag: $(Build.BuildNumber) | |
| pushTag: latest | |
| repositoryName: $(AWS_ECR_REPOSITORY_NAME) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment