ProHoster > Блог > Kev tswj hwm > Teeb tsa GitLab CI los upload ib qhov project java rau maven central
Teeb tsa GitLab CI los upload ib qhov project java rau maven central
Cov kab lus no yog npaj rau java developers uas xav tau sai sai tshaj tawm lawv cov khoom nyob rau hauv sonatype thiab / los yog maven central repositories siv GitLab. Hauv tsab xov xwm no kuv yuav tham txog kev teeb tsa gitlab-khiav, gitlab-ci thiab maven-plugin los daws qhov teeb meem no.
Yam yuavtsum tau kawm uantej:
Ruaj ntseg cia ntawm mvn thiab GPG yuam sij.
Ua kom muaj kev nyab xeeb ntawm pej xeem CI cov haujlwm.
Cov lus piav qhia ntxaws ntxaws ntawm cov txheej txheem rau kev tshaj tawm cov khoom cuav hauv Maven Central ntawm Sonatype OSS Repository Hosting Service twb tau piav qhia hauv tsab xov xwm no tus neeg siv Googolplex, yog li kuv yuav xa mus rau tsab xov xwm no hauv qhov chaw zoo.
Pre-register rau Sonatype JIRA thiab qhib ib daim pib mus qhib lub repository (nyeem cov seem kom paub meej ntxiv Tsim ib daim pib ntawm Sonatype JIRA). Tom qab qhib lub repository, tus ID nkag mus / lo lus zais khub los ntawm JIRA (tom qab no hu ua Sonatype account) yuav raug siv los upload cov khoom cuav rau Sonatype nexus.
Tom ntej no, cov txheej txheem ntawm kev tsim tus yuam sij GPG tau piav qhia qhuav heev. Saib seem kom paub meej ntxiv Configuring GnuPG rau kos npe artifacts
Yog tias koj siv lub console Linux los tsim tus yuam sij GPG (gnupg/gnupg2), ces koj yuav tsum tau nruab rng-cuab yeej los tsim entropy. Txwv tsis pub, cov cim tseem ceeb yuav siv sij hawm ntev heev.
Ua ntej tshaj plaws, koj yuav tsum tsim thiab teeb tsa ib qhov project uas lub raj xa dej yuav raug muab khaws cia rau kev xa cov khoom cuav. Kuv tau hu kuv qhov project yooj yim thiab tsis yooj yim - deploy
Tom qab tsim lub repository, koj yuav tsum txwv tsis pub nkag mus hloov lub repository.
Mus rau qhov project -> Chaw -> Repository -> Tiv thaiv ceg. Peb tshem tawm tag nrho cov cai thiab ntxiv ib txoj cai nrog Wildcard * nrog rau txoj cai thawb thiab sib koom ua ke tsuas yog rau cov neeg siv nrog lub luag haujlwm Tus Saib Xyuas. Txoj cai no yuav ua haujlwm rau txhua tus neeg siv ntawm ob qho haujlwm no thiab pab pawg uas qhov haujlwm no koom nrog.
Yog tias muaj ntau tus neeg saib xyuas, ces qhov kev daws teeb meem zoo tshaj plaws yuav txwv tsis pub nkag mus rau qhov project hauv txoj cai.
Mus rau qhov project -> Chaw -> General -> Visibility, qhov project nta, kev tso cai thiab teeb qhov pom kev rau qhov project private.
Kuv muaj ib txoj haujlwm siv tau rau pej xeem, txij li thaum kuv siv kuv tus kheej GitLab Runner thiab tsuas yog kuv muaj kev nkag mus hloov lub chaw cia khoom. Zoo, qhov tseeb, nws tsis yog nyob rau hauv kuv qhov kev txaus siab los qhia cov ntaub ntawv ntiag tug hauv pej xeem cov kav dej cav.
Tightening cov cai rau kev hloov lub repository
Mus rau qhov project -> Chaw -> Repository -> Push Rules thiab teeb tsa Committer txwv, Xyuas seb tus sau yog tus neeg siv tus chij GitLab. Kuv kuj pom zoo kom teeb tsa cog lus kos npe, thiab teem lub Reject unsigned commits chij.
Tom ntej no koj yuav tsum configure ib tug trigger rau tso tej hauj lwm
Mus rau qhov project -> Chaw -> CI / CD -> Pipeline triggers thiab tsim ib tug tshiab trigger-token
Cov token no tuaj yeem raug ntxiv tam sim ntawd rau qhov kev teeb tsa dav dav ntawm qhov hloov pauv rau ib pawg ntawm cov haujlwm.
Mus rau pab pawg -> Chaw -> CI / CD -> Hloov pauv thiab ntxiv qhov sib txawv DEPLOY_TOKEN nrog trigger-token hauv tus nqi.
Runtime platform arch=amd64 os=linux pid=17594 revision=3001a600 version=11.10.0
Running in system-mode.
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
https://gitlab.com/
Please enter the gitlab-ci token for this runner:
REGISTRATION_TOKEN
Please enter the gitlab-ci description for this runner:
[ih1174328.vds.myihor.ru]: Deploy Runner
Please enter the gitlab-ci tags for this runner (comma separated):
deploy
Registering runner... succeeded runner=ZvKdjJhx
Please enter the executor: docker-ssh, parallels, virtualbox, docker-ssh+machine, kubernetes, docker, ssh, docker+machine, shell:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
Peb xyuas tias tus khiav tau sau npe. Mus rau lub vev xaib gitlab.com -> deploy-project -> Chaw -> CI/CD -> Runners -> Specific Runners -> Runners activated for this project
Lub ntsiab lus no tau piav qhia ntau yam. Googolplex в Teeb tsa maven kom tau kos npe thiab xa cov khoom qub rau snapshot thiab staging repositories, yog li kuv yuav piav qhia qee qhov nuances ntawm kev siv plugins. Kuv tseem yuav piav qhia seb koj siv tau yooj yim thiab so nexus-staging-maven-pluginyog tias koj tsis xav tau lossis siv tsis tau org.sonatype.oss:oss-niam txiv ua niam txiv rau koj qhov project.
Tom qab rub tawm, snapshot / tso tawm versions muaj nyob rau hauv staging repositories
<repositories>
<repository>
<id>SonatypeNexus</id>
<url>https://oss.sonatype.org/content/groups/staging/</url>
<!-- Не надо указывать флаги snapshot/release для репозитория -->
</repository>
</repositories>
Ntau pluses
Ib daim ntawv teev npe nplua nuj ntawm cov hom phiaj rau kev ua haujlwm nrog lub chaw cia khoom sib txuas (mvn help:describe -Dplugin=org.sonatype.plugins:nexus-staging-maven-plugin).
[INFO] Performing remote staging...
[INFO]
[INFO] * Remote staging into staging profile ID "9043b43f77dcc9"
[INFO] * Created staging repository with ID "orgtouchbit-1037".
[INFO] * Staging repository at https://oss.sonatype.org:443/service/local/staging/deployByRepositoryId/orgtouchbit-1037
[INFO] * Uploading locally staged artifacts to profile org.touchbit
[INFO] * Upload of locally staged artifacts finished.
[INFO] * Closing staging repository with ID "orgtouchbit-1037".
Waiting for operation to complete...
.........
[INFO] Remote staged 1 repositories, finished with success.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Shields4J 1.0.0 .................................... SUCCESS [ 9.603 s]
[INFO] test-core .......................................... SUCCESS [ 3.419 s]
[INFO] Shields4J client ................................... SUCCESS [ 9.793 s]
[INFO] TestNG listener 1.0.0 .............................. SUCCESS [01:23 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:47 min
[INFO] Finished at: 2019-04-21T04:05:46+03:00
[INFO] ------------------------------------------------------------------------
Thiab yog tias muaj ib yam dab tsi tsis ncaj ncees lawm, txoj haujlwm yuav ua tsis tiav
[INFO] Performing remote staging...
[INFO]
[INFO] * Remote staging into staging profile ID "9043b43f77dcc9"
[INFO] * Created staging repository with ID "orgtouchbit-1038".
[INFO] * Staging repository at https://oss.sonatype.org:443/service/local/staging/deployByRepositoryId/orgtouchbit-1038
[INFO] * Uploading locally staged artifacts to profile org.touchbit
[INFO] * Upload of locally staged artifacts finished.
[INFO] * Closing staging repository with ID "orgtouchbit-1038".
Waiting for operation to complete...
.......
[ERROR] Rule failure while trying to close staging repository with ID "orgtouchbit-1039".
[ERROR]
[ERROR] Nexus Staging Rules Failure Report
[ERROR] ==================================
[ERROR]
[ERROR] Repository "orgtouchbit-1039" failures
[ERROR] Rule "signature-staging" failures
[ERROR] * No public key: Key with id: (1f42b618d1cbe1b5) was not able to be located on <a href=http://keys.gnupg.net:11371/>http://keys.gnupg.net:11371/</a>. Upload your public key and try the operation again.
...
[ERROR] Cleaning up local stage directory after a Rule failure during close of staging repositories: [orgtouchbit-1039]
[ERROR] * Deleting context 9043b43f77dcc9.properties
[ERROR] Cleaning up remote stage repositories after a Rule failure during close of staging repositories: [orgtouchbit-1039]
[ERROR] * Dropping failed staging repository with ID "orgtouchbit-1039" (Rule failure during close of staging repositories: [orgtouchbit-1039]).
[ERROR] Remote staging finished with a failure: Staging rules failure!
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Shields4J 1.0.0 .................................... SUCCESS [ 4.073 s]
[INFO] test-core .......................................... SUCCESS [ 2.788 s]
[INFO] Shields4J client ................................... SUCCESS [ 3.962 s]
[INFO] TestNG listener 1.0.0 .............................. FAILURE [01:07 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
Yog li ntawd, peb tsuas tshuav ib qho kev xaiv xwb. Los yog rho tawm no version los yog luam tawm nws.
Tom qab tso tawm, tom qab qee lub sijhawm cov khoom qub yuav nyob hauv
Lub Deploy project yog cais los ntawm kev cuam tshuam sab nraud thiab tsuas yog hloov tau los ntawm cov neeg siv nrog Tus Tswv thiab Tus Saib Xyuas lub luag haujlwm.
Ib qho tshwj xeeb Runner nrog "kub" cache kom khiav tsuas yog xa cov dej num.
Publishing snapshot/release versions in a public repository.
Ib qho chaw khaws cia rau kev tau txais snapshot / tso tawm versions.
General pipeline rau lub tsev / kuaj / luam tawm ib qhov project java.
Kev teeb tsa GitLab CI tsis yog ib lub ntsiab lus nyuaj raws li nws zoo nkaus li thaum xub thawj siab ib muag. Nws yog txaus los teeb tsa CI ntawm lub hauv paus turnkey ob peb zaug, thiab tam sim no koj nyob deb ntawm tus neeg nyiam ua haujlwm hauv qhov teeb meem no. Ntxiv mus, GitLab cov ntaub ntawv yog qhov tsis txaus ntseeg heev. Tsis txhob ntshai ua thawj kauj ruam. Txoj kev tshwm nyob rau hauv cov kauj ruam ntawm tus neeg taug kev (Kuv tsis nco qab leej twg hais nws :)
Kuv yuav zoo siab tau txais cov lus qhia.
Hauv tsab xov xwm tom ntej no kuv yuav tham txog yuav ua li cas teeb tsa GitLab CI los khiav cov haujlwm nrog kev sib koom ua ke kev sib tw (khiav cov kev pabcuam hauv kev sim siv docker-compose) yog tias koj tsuas muaj ib lub plhaub khiav.