First commit.

This commit is contained in:
Andrea Dell'Amico 2024-05-14 19:14:48 +02:00
parent 75a8938ba6
commit 3ea0e38209
Signed by: andrea.dellamico
GPG Key ID: 147ABE6CEB9E20FF
3 changed files with 29 additions and 27 deletions

8
Dockerfile Normal file
View File

@ -0,0 +1,8 @@
FROM openjdk:17
RUN mkdir -p /opt/shinyproxy
RUN wget https://shinyproxy.io/downloads/shinyproxy-3.1.0.jar -O /opt/shinyproxy/shinyproxy.jar
WORKDIR /opt/shinyproxy
CMD ["java", "-jar", "/opt/shinyproxy/shinyproxy.jar"]

35
Jenkinsfile vendored
View File

@ -9,18 +9,19 @@ pipeline {
label 'docker'
}
environment {
imagename = "" //TO FILL WITH THE RIGHT VALUE (RepositoryName) e.g. d4science/RepositoryName
registryCredential = 'e348bfab-5580-4db6-b0e0-d854966bde08'
dockerImage = ''
git_url='' // SET HERE THE URL OF YOUR NEW GIT PROJECT
imagename = "external-services/shinyproxy"
hubname = "hub.dev.d4science.org"
registryUrl = "https://hub.dev.d4science.org"
registryCredential = 'harbor-dev-external-services'
dockerImage = ''
git_url='https://code-repo.d4science.org/InfraScience/shinyproxy-infrascience.git'
}
stages {
stage('Cloning Git') {
steps {
git([url: git_url, branch: 'master', credentialsId: '88b54962-1c0e-49cb-8155-22276860f346'])
}
}
// stage('Cloning Git') {
// steps {
// git([url: git_url, branch: 'main', credentialsId: ''])
// }
// }
stage('Building image') {
steps{
script {
@ -31,18 +32,17 @@ pipeline {
stage('Deploy Image') {
steps{
script {
docker.withRegistry( '', registryCredential ) {
docker.withRegistry( registryUrl, registryCredential ) {
dockerImage.push("$BUILD_NUMBER")
dockerImage.push('latest')
dockerImage.push('latest')
}
}
}
}
stage('Remove Unused docker image') {
steps{
sh "docker rmi $imagename:$BUILD_NUMBER"
sh "docker rmi $imagename:latest"
sh "docker rmi $hubname/$imagename:$BUILD_NUMBER"
sh "docker rmi $hubname/$imagename:latest"
}
}
@ -50,9 +50,9 @@ pipeline {
// post-build actions
post {
success {
echo 'The docker pipeline worked!'
echo 'The shinyproxy docker pipeline worked!'
emailext to: 'jenkinsbuilds@d4science.org',
subject: "[Jenkins DockerPipeline D4S] build ${currentBuild.fullDisplayName} worked",
subject: "[Jenkins Docker Pipeline D4S] ${currentBuild.fullDisplayName} build worked",
body: "Build time: ${currentBuild.durationString}. See ${env.BUILD_URL}"
}
failure {
@ -64,3 +64,4 @@ pipeline {
}
}
}

View File

@ -1,12 +1,5 @@
# Pipeline-Docker-Template
# Shinyproxy
This is a template useful for building docker images and push to dockerhub.
There is a jenkinsjob template on our jenkins with the same name.
Jenkins pipeline that builds shinyproxy. The main branch tags the built image as "latest".
Create a branch and add a corresponding Jenkins job if you want to build a specific version.
## USAGE TIPS:
* REMEMBER TO FILL the jenkinsfile environment section with your values. The following field should be properly filled: imagename, git_url
* REMEMBER TO PUT your Dockerfile in the root folder of your new project
* You can find the related jenkinsjob template here: https://jenkins.d4science.org/job/Pipeline-Docker-Template/