-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathJenkinsfile-4
33 lines (33 loc) · 999 Bytes
/
Jenkinsfile-4
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
def timeInMillis = currentBuild.timeInMillis
def imageTag = "darinpope/alpine:" + timeInMillis
@Library("shared-library") _
pipeline {
agent any
environment {
DH_CREDS=credentials('dh-creds')
}
stages {
stage('Hello') {
steps {
sh """
echo "FROM alpine:latest" > Dockerfile
docker build -t ${imageTag} .
"""
sh '''
echo $DH_CREDS_PSW | docker login --username=$DH_CREDS_USR --password-stdin
'''
script {
def sha256 = sh(returnStdout: true, script:"docker push ${imageTag} | grep sha256 | awk -F':' '{print \$4}' | awk '{print \$1}'").trim()
echo sha256
def url = "https://hub.docker.com/layers/" + env.DH_CREDS_USR + "/alpine/" + timeInMillis + "/images/sha256-" + sha256 + "?context=explore"
addSidebarLink(url:url,text:"Image on Docker Hub",icon:"star.gif")
}
}
post {
always {
sh 'docker logout'
}
}
}
}
}