image: harbor.javalabs.com.cn/javalabs-tools/commonbase:0.0.1 variables: image: 7 tag: 0.0.1 mvnrepo: /root/.m2/repository groupid: 1 grouppath: 2 artifactid: 3 artifactid_admin: 4 version: 5 jarname: 6 harborurl: harbor.javalabs.com.cn/operation-vems before_script: - ls /usr/local/pythonfolder/ - cp /usr/local/pythonfolder/readpom.py ./ - gid_aid_ver=$(python readpom.py) - echo $gid_aid_ver - IFS=‘,‘ arr=($gid_aid_ver) - groupid=${arr[0]} - grouppath=${arr[3]} - artifactid=${arr[1]} - artifactid_admin=$artifactid-admin - version=${arr[2]} - jarname=$artifactid_admin-$version.jar - image=(${artifactid_admin,,}) - pwd - echo $groupid - echo $artifactid - echo $version - echo $grouppath stages: - makepushjar - makepushimage make_push_jar: stage: makepushjar script: - echo "----------------------make_push_jar start -----------------------------------------" - echo $groupid - echo $artifactid - echo $version - mvn clean install -U -Dmaven.test.skip=true - ls - mvn deploy:deploy-file -DgroupId=$groupid -DartifactId=$artifactid -Dversion=$version -Dpackaging=jar -Dfile=$mvnrepo/$grouppath/$artifactid_admin/$version/$jarname -Durl=https://nexus.javalabs.com.cn/repository/javalabs-nexus/ -DrepositoryId=javalabs-nexus - echo "----------------------make_push_jar end -------------------------------------------" make_push_image: stage: makepushimage script: - echo "----------------------make_push_image start -----------------------------------------" - cp $mvnrepo/$grouppath/$artifactid_admin/$version/$jarname ./$jarname - docker build -t $image:$tag --build-arg JARNAME=$artifactid_admin-$version . - rm -rf $mvnrepo/$grouppath/$artifactid_admin/$version/ - rm -rf ./$jarname - docker login --username=admin --password=Harbor12345 harbor.javalabs.com.cn - docker tag $image:$tag $harborurl/$image:$tag - docker push $harborurl/$image:$tag - docker images - docker ps -a - echo "----------------------make_push_image end -------------------------------------------"
原文:https://www.cnblogs.com/chuyuan/p/12197925.html