-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile-ACR
45 lines (38 loc) · 1.32 KB
/
Jenkinsfile-ACR
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//This pipeline uploads your containers to Azure Container Registry
pipeline {
agent any
environment {
//Change the name for your name registry created in the azure portal
registryName = "Name"
//Here you reference a credential saved in jenkins
registryCredential = 'CredentialName'
dockerImage = ''
//Here you specity the URL of your container registry
registryUrl = '<Name>.azurecr.io'
}
stages {
stage ('checkout') {
steps {
//You can generate you checkout code in the section pipeline syntax
checkout([$class: 'GitSCM', branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[credentialsId: 'YourCredentialID', url: 'YourRepositoryURL(Github,Gitlab...)']]])
}
}
stage ('Build Docker image') {
steps {
script {
dockerImage = docker.build registryName
}
}
}
// Uploading Docker images into Azure Container Registry
stage('Upload Image to ACR') {
steps{
script {
docker.withRegistry( "http://${registryUrl}", registryCredential ) {
dockerImage.push()
}
}
}
}
}
}