From bd980e8fc7f7dbb23c0e38f3db0cab2ad55365a4 Mon Sep 17 00:00:00 2001 From: NetOps <idcnetops@tarento.com> Date: Tue, 25 Jan 2022 13:46:58 +0000 Subject: [PATCH] Add new file --- Jenkinsfile | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..4655b6d --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,50 @@ +node() { + try { + String ANSI_GREEN = "\u001B[32m" + String ANSI_NORMAL = "\u001B[0m" + String ANSI_BOLD = "\u001B[1m" + String ANSI_RED = "\u001B[31m" + String ANSI_YELLOW = "\u001B[33m" + + ansiColor('xterm') { + stage('Checkout') { + cleanWs() + checkout scm + } + } + stage('docker-pre-build') { + sh ''' + + docker build --no-cache -f ./Dockerfile.build -t $docker_pre_build . + docker run --name $docker_pre_build $docker_pre_build:latest && docker cp $docker_pre_build:/opt/target/zuul-0.0.1-SNAPSHOT.jar . + docker rm -f $docker_pre_build + docker rmi -f $docker_pre_build + ''' + } + + stage('docker-build') { + sh ''' + commit_id=$(git rev-parse --short HEAD) + echo $commit_id> commit_id.txt + docker build --no-cache -f Dockerfile -t $docker_server/$docker_repo:$commit_id . + docker tag $docker_server/$docker_repo:$commit_id $docker_server/$docker_repo:$image_tag + ''' + } + stage('docker-push') { + + sh ''' + pwd + commit_id=$(git rev-parse --short HEAD) + docker push $docker_server/$docker_repo:$commit_id + docker push $docker_server/$docker_repo:$image_tag + docker rmi -f $docker_server/$docker_repo:$commit_id + docker rmi -f $docker_server/$docker_repo:$image_tag + ''' + } + +} + catch (err) { + currentBuild.result = "FAILURE" + throw err + } +} -- GitLab