java ပရောဂျက်တစ်ခုကို maven ဗဟိုသို့ အပ်လုဒ်လုပ်ရန် GitLab CI ကို စနစ်ထည့်သလင်သခဌင်သ။

ကဆောင်သပါသသည် GitLab ကို အသုံသပဌု၍ sonatype နဟင့်/သို့မဟုတ် maven ဗဟိုသိုလဟောင်ခန်သမျာသတလင် ၎င်သတို့၏ ထုတ်ကုန်မျာသကို လျင်မဌန်စလာ ထုတ်ဝေလိုသည့် java developer မျာသအတလက် ရည်ရလယ်ပါသည်။ ကဆောင်သပါသတလင် ကပဌဿနာကိုဖဌေရဟင်သရန် gitlab-runner၊ gitlab-ci နဟင့် maven-plugin ကိုတည်ဆောက်ခဌင်သအကဌောင်သပဌောပါမည်။

လိုအပ်ချက်မျာသ

  • mvn နဟင့် GPG သော့မျာသကို လုံခဌုံစလာသိမ်သဆည်သပါ။
  • အမျာသသူငဟာ CI လုပ်ငန်သမျာသကို လုံခဌုံစလာ အကောင်အထည်ဖော်ခဌင်သ။
  • ရဟေသဟောင်သပစ္စည်သမျာသ (ထုတ်လလဟတ်ခဌင်သ/လျဟပ်တစ်ပဌက်) ကို အမျာသသူငဟာ သိုလဟောင်ရာမျာသသို့ အပ်လုဒ်လုပ်ခဌင်သ။
  • maven Central တလင် ထုတ်ဝေရန်အတလက် ထလက်ရဟိသောဗာသရဟင်သမျာသကို အလိုအလျောက်စစ်ဆေသခဌင်သ။
  • ပရောဂျက်မျာသစလာအတလက် ရဟေသဟောင်သပစ္စည်သမျာသကို သိုလဟောင်ရုံသို့ အပ်လုဒ်တင်ခဌင်သအတလက် ယေဘုယျဖဌေရဟင်သချက်။
  • ရိုသရဟင်သမဟုနဟင့် အသုံသပဌုရလလယ်ကူခဌင်သ။

အကဌောင်သအရာ

ယေဘုယျသတင်သအချက်အလက်

  • Sonatype OSS Repository Hosting Service မဟတစ်ဆင့် Maven Central တလင် ရဟေသဟောင်သပစ္စည်သမျာသ ဖဌန့်ချိသည့် ယန္တရာသ၏ အသေသစိတ်ဖော်ပဌချက်ကို တလင် ဖော်ပဌထာသပဌီသဖဌစ်သည်။ ကဆောင်ပါသ အသုံသပဌုသူကို Googolplexထို့ကဌောင့် ကျလန်ုပ်သည် ကဆောင်သပါသကို မဟန်ကန်သောနေရာမျာသတလင် ကိုသကာသပါမည်။
  • ကဌိုတင်စာရင်သပေသသလင်သပါ။ Sonatype JIRA သိုလဟောင်ရုံကိုဖလင့်ရန် လက်မဟတ်တစ်စောင်ကိုဖလင့်ပါ (အသေသစိတ်အချက်အလက်မျာသအတလက် အပိုင်သကို ဖတ်ရဟုပါ။ Sonatype JIRA တလင် လက်မဟတ်တစ်ခု ဖန်တီသပါ။) repository ကိုဖလင့်ပဌီသနောက်၊ JIRA မဟ လော့ဂ်အင်/စကာသဝဟက်အတလဲ (ယခုနောက်ပိုင်သတလင် Sonatype အကောင့်အဖဌစ်ရည်ညလဟန်သသည်) ကို Sonatype nexus သို့ ရဟေသဟောင်သပစ္စည်သမျာသ အပ်လုဒ်လုပ်ရန်အတလက် အသုံသပဌုပါမည်။
  • ထို့နောက်၊ GPG သော့ထုတ်ပေသခဌင်သလုပ်ငန်သစဉ်ကို အလလန်ခဌောက်သလေ့စလာဖော်ပဌသည်။ အသေသစိတ်အချက်အလက်မျာသအတလက် ကဏ္ဍကို ကဌည့်ပါ။ ရဟေသဟောင်သပစ္စည်သမျာသကို လက်မဟတ်ထိုသရန် GnuPG ကို ပဌင်ဆင်သတ်မဟတ်ခဌင်သ။
  • အကယ်၍ သင်သည် GPG သော့ (gnupg/gnupg2) ကိုထုတ်လုပ်ရန် Linux ကလန်ဆိုသလ်ကိုအသုံသပဌုပါက သင်ထည့်သလင်သရန်လိုအပ်သည် RNG-tools မျာသ entropy ကိုထုတ်လုပ်ရန်။ မဟုတ်ပါက သော့မျိုသဆက်သည် အလလန်အချိန်ယူရပေမည်။
  • သိုလဟောင်ခဌင်သဝန်ဆောင်မဟုမျာသ အမျာသသူငဟာ GPG သော့မျာသ

အကဌောင်သအရာရန်

GitLab တလင် ဖဌန့်ကျက် ပရောဂျက်တစ်ခု တည်ဆောက်ခဌင်သ။

  • ပထမညသစလာ၊ သင်သည် ရဟေသဟောင်သပစ္စည်သမျာသကို အသုံသချရန်အတလက် ပိုက်လိုင်သကို သိမ်သဆည်သမည့် ပရောဂျက်တစ်ခုကို ဖန်တီသပဌီသ ပဌင်ဆင်သတ်မဟတ်ရန် လိုအပ်သည်။ ကျလန်ုပ်၏ ပရောဂျက်ကို ရိုသရိုသရဟင်သရဟင်သနဟင့် ရဟုပ်ထလေသစလာ အမည်ပေသခဲ့ပါသည်။ ကျယ်ပဌန့်
  • repository ကိုဖန်တီသပဌီသနောက်၊ repository ကိုပဌောင်သလဲရန်ဝင်ရောက်ခလင့်ကိုသင်ကန့်သတ်ရန်လိုအပ်သည်။
    ပရောဂျက် -> ဆက်တင်မျာသ -> သိုလဟောင်ရေသ -> အကာအကလယ်ဌာနခလဲမျာသသို့ သလာသပါ။ ကျလန်ုပ်တို့သည် စည်သမျဉ်သမျာသအာသလုံသကို ဖျက်ပဌီသ စည်သကမ်သချက်တစ်ခုတည်သကို Wildcard * ဖဌင့် ထိန်သညဟိပေသသည့် အခန်သကဏ္ဍဖဌင့် အသုံသပဌုသူမျာသအတလက်သာ တလန်သအာသပေသပဌီသ ပေါင်သစည်သပိုင်ခလင့်ရဟိသည်။ ကစည်သမျဉ်သသည် ကပရောဂျက်နဟစ်ခုလုံသနဟင့် ကပရောဂျက်ပိုင်ဆိုင်သည့်အဖလဲ့၏ အသုံသပဌုသူအာသလုံသအတလက် အလုပ်လုပ်မည်ဖဌစ်သည်။
    java ပရောဂျက်တစ်ခုကို maven ဗဟိုသို့ အပ်လုဒ်လုပ်ရန် GitLab CI ကို စနစ်ထည့်သလင်သခဌင်သ။
  • ထိန်သသိမ်သသူအမျာသအပဌာသရဟိပါက၊ အကောင်သဆုံသဖဌေရဟင်သချက်မဟာ ပရောဂျက်သို့ဝင်ရောက်ခလင့်ကိုမူအရကန့်သတ်ရန်ဖဌစ်သည်။
    ပရောဂျက် -> ဆက်တင်မျာသ -> အထလေထလေ -> မဌင်နိုင်မဟု၊ ပရောဂျက်အင်္ဂါရပ်မျာသ၊ ခလင့်ပဌုချက်မျာသကို သလာသပဌီသ ပရောဂျက်မဌင်နိုင်စလမ်သကို သတ်မဟတ်ပါ။ ကိုယ်ပိုင်.
    ကျလန်ုပ်သည် ကျလန်ုပ်၏ကိုယ်ပိုင် GitLab Runner ကိုအသုံသပဌုပဌီသ repository ကိုပဌောင်သလဲရန် တစ်ညသတည်သသာ ဝင်ရောက်ခလင့်ရဟိသောကဌောင့် ကျလန်ုပ်တလင် အမျာသသူငဟာ အသုံသပဌုနိုင်သော ပရောဂျက်တစ်ခုရဟိသည်။ အမဟန်တော့၊ အမျာသသူငဟာ ပိုက်လိုင်သမဟတ်တမ်သမျာသတလင် ကိုယ်ရေသကိုယ်တာအချက်အလက်မျာသကိုပဌသရန် ကျလန်ုပ်၏အကျိုသစီသပလာသမဟုတ်ပါ။
  • သိုလဟောင်မဟုအာသ ပဌောင်သလဲခဌင်သအတလက် စည်သမျဉ်သမျာသ တင်သကျပ်ခဌင်သ။
    ပရောဂျက် -> Settings -> Repository -> Push Rules ကိုသလာသပဌီသ Committer ကန့်သတ်ချက်ကို သတ်မဟတ်ပါ၊ စာရေသသူသည် GitLab အသုံသပဌုသူအလံမျာသ ဟုတ်မဟုတ် စစ်ဆေသပါ။ တပ်ဆင်ရန်လည်သ အကဌံပဌုပါသည်။ လက်မဟတ်ထိုသပါ။နဟင့် Reject unsigned commits အလံကို သတ်မဟတ်ပါ။
  • ထို့နောက် လုပ်ဆောင်စရာမျာသကို စတင်ရန် အစပျိုသတစ်ခုကို သတ်မဟတ်ရန် လိုအပ်သည်။
    ပရောဂျက် -> ဆက်တင်မျာသ -> CI / CD -> ပိုက်လိုင်သအစပျိုသမဟုမျာသသို့ သလာသပဌီသ အစပျိုသ-တိုကင်အသစ်တစ်ခု ဖန်တီသပါ။
    ကတိုကင်ကို ပရောဂျက်အုပ်စုတစ်ခုအတလက် ကိန်သရဟင်မျာသ၏ ယေဘုယျဖလဲ့စည်သပုံတလင် ချက်ချင်သထည့်နိုင်သည်။
    group -> Settings -> CI / CD -> Variables သို့သလာသ၍ variable ကိုထည့်ပါ။ DEPLOY_TOKEN တန်ဖိုသရဟိ trigger-token နဟင့်အတူ။

အကဌောင်သအရာရန်

GitLab အပဌေသသမာသ

သင့်ကိုယ်ပိုင် (Specific) နဟင့် အမျာသသူငဟာ (မျဟဝေထာသသော) အပဌေသသမာသကို အသုံသပဌု၍ ဖဌန့်ကျက်လုပ်ဆောင်သည့် လုပ်ဆောင်စရာမျာသကို လုပ်ဆောင်ရန်အတလက် ဖလဲ့စည်သမဟုပုံစံကို ကကဏ္ဍတလင် ဖော်ပဌထာသသည်။

သတ်သတ်မဟတ်မဟတ် အပဌေသသမာသ

ပထမဆုံသအနေနဲ့ အဆင်ပဌေတယ်၊ ​​မဌန်တယ်၊ စျေသပေါတယ်၊ ဘာကဌောင့်လဲဆိုတော့ ကိုယ့်ကိုယ်ပိုင် အပဌေသသမာသတလေကို သုံသတယ်။
အပဌေသသမာသအတလက်၊ CPU 1၊ 2 GB RAM၊ 20 GB HDD ပါသော Linux VDS ကို အကဌံပဌုပါသည်။ ထုတ်ပေသသောစျေသနဟုန်သမဟာ တစ်နဟစ်လျဟင် ~3000â‚œ ဖဌစ်သည်။

ငါ့အပဌေသသမာသ

အပဌေသသမာသအတလက် ကျလန်ုပ်သည် VDS 4 CPU၊ 4 GB RAM ၊ 50 GB SSD ကို ယူခဲ့သည်။ ~11000â‚œ ကုန်ကျပဌီသ ဘယ်တော့မဟ နောင်တမရပါဘူသ။
စုစုပေါင်သ စက် ၇ လုံသရဟိတယ်။ Aruba တလင် 7 နဟင့် 5 ihor ။

အဲဒီတော့ အပဌေသသမာသရဟိတယ်။ ယခု ကျလန်ုပ်တို့ ၎င်သကို configure လုပ်ပါမည်။
SSH မဟတစ်ဆင့် စက်သို့သလာသ၍ java, git, maven, gnupg2 ကို install လုပ်ပါ။

အကဌောင်သအရာရန်

gitlab runner ကို ထည့်သလင်သခဌင်သ။

  • အဖလဲ့အသစ်တစ်ခုဖန်တီသပါ။ runner
    sudo groupadd runner
  • maven ကက်ရဟ်အတလက် လမ်သညလဟန်တစ်ခုဖန်တီသပဌီသ အဖလဲ့ခလင့်ပဌုချက်မျာသကို သတ်မဟတ်ပါ။ runner
    စက်တစ်လုံသတလင် အပဌေသသမာသအမျာသအပဌာသကို လည်ပတ်ရန် အစီအစဉ်မရဟိပါက ကအမဟတ်ကို ကျော်သလာသနိုင်သည်။

    mkdir -p /usr/cache/.m2/repository
    chown -R :runner /usr/cache
    chmod -R 770 /usr/cache
  • အသုံသပဌုသူဖန်တီသပါ။ gitlab-deployer နဟင့်အဖလဲ့သို့ထည့်ပါ။ runner
    useradd -m -d /home/gitlab-deployer gitlab-deployer
    usermod -a -G runner gitlab-deployer
  • ဖိုင်သို့ထည့်ပါ။ /etc/ssh/sshd_config နောက်တစ်ကဌောင်သ
    AllowUsers root@* [email protected]
  • ပဌန်ဖလင့်ပါ။ sshd
    systemctl restart sshd
  • အသုံသပဌုသူအတလက် စကာသဝဟက်တစ်ခု သတ်မဟတ်ခဌင်သ။ gitlab-deployer (Localhost အတလက် ကန့်သတ်ချက်တစ်ခု ရဟိသောကဌောင့် ရိုသရဟင်သနိုင်ပါသည်။)
    passwd gitlab-deployer
  • GitLab Runner (Linux x86-64) ကို ထည့်သလင်သပါ။
    sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
    sudo chmod +x /usr/local/bin/gitlab-runner
    ln -s /usr/local/bin/gitlab-runner /etc/alternatives/gitlab-runner
    ln -s /etc/alternatives/gitlab-runner /usr/bin/gitlab-runner
  • gitlab.com -> deploy-project -> Settings -> CI/CD -> Runners -> Specific Runners သို့သလာသ၍ မဟတ်ပုံတင်ထာသသော တိုကင်ကို ကူသယူပါ။

မျက်နဟာပဌင်

java ပရောဂျက်တစ်ခုကို maven ဗဟိုသို့ အပ်လုဒ်လုပ်ရန် GitLab CI ကို စနစ်ထည့်သလင်သခဌင်သ။

  • အပဌေသသမာသ မဟတ်ပုံတင်ခဌင်သ။
    gitlab-runner register --config /etc/gitlab-runner/gitlab-deployer-config.toml

ဖဌစ်စဉ်

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!

  • အပဌေသသမာသစာရင်သသလင်သပဌီသကဌောင်သ စစ်ဆေသပါတယ်။ gitlab.com -> deploy-project -> ဆက်တင်မျာသ -> CI/CD -> Runners -> Specific Runners -> Runners မျာသကို ကပရောဂျက်အတလက် activated

မျက်နဟာပဌင်

java ပရောဂျက်တစ်ခုကို maven ဗဟိုသို့ အပ်လုဒ်လုပ်ရန် GitLab CI ကို စနစ်ထည့်သလင်သခဌင်သ။

  • ထည့်ပါ သီသခဌာသ ဝန်ဆောင်မဟု /etc/systemd/system/gitlab-deployer.service
    [Unit]
    Description=GitLab Deploy Runner
    After=syslog.target network.target
    ConditionFileIsExecutable=/usr/local/bin/gitlab-runner
    [Service]
    StartLimitInterval=5
    StartLimitBurst=10
    ExecStart=/usr/local/bin/gitlab-runner "run" "--working-directory" "/home/gitlab-deployer" "--config" "/etc/gitlab-runner/gitlab-deployer-config.toml" "--service" "gitlab-deployer" "--syslog" "--user" "gitlab-deployer"
    Restart=always
    RestartSec=120
    [Install]
    WantedBy=multi-user.target
  • ဝန်ဆောင်မဟုကို စလိုက်ရအောင်။
    systemctl enable gitlab-deployer.service
    systemctl start gitlab-deployer.service
    systemctl status gitlab-deployer.service
  • အပဌေသသမာသက ပဌေသနေတာကို စစ်ဆေသတယ်။

နမူနာ

java ပရောဂျက်တစ်ခုကို maven ဗဟိုသို့ အပ်လုဒ်လုပ်ရန် GitLab CI ကို စနစ်ထည့်သလင်သခဌင်သ။

အကဌောင်သအရာရန်

GPG သော့မျာသထုတ်ပေသခဌင်သ။

  • တူညီသောစက်မဟအသုံသပဌုသူအောက်ရဟိ ssh မဟတဆင့်ကျလန်ုပ်တို့ဝင်ရောက်သည်။ gitlab-deployer (၎င်သသည် GPG သော့ကိုဖန်တီသရန်အတလက် အရေသကဌီသသည်)

    ssh [email protected]

  • ကျလန်ုပ်တို့သည် မေသခလန်သမျာသကိုဖဌေဆိုခဌင်သဖဌင့် သော့တစ်ခုထုတ်ပေသပါသည်။ ကိုယ့်နာမည်နဲ့ အီသမေသလ်ကို သုံသတယ်။
    သော့အတလက် စကာသဝဟက်ကို သေချာသတ်မဟတ်ပါ။ ပစ္စည်သမျာသကို ကသော့ဖဌင့် လက်မဟတ်ရေသထိုသပါမည်။

    gpg --gen-key 

  • ယင်သစစ်ဆေသ

    gpg --list-keys -a
    /home/gitlab-deployer/.gnupg/pubring.gpg
    ----------------------------------------
    pub   4096R/00000000 2019-04-19
    uid                  Petruha Petrov <[email protected]>
    sub   4096R/11111111 2019-04-19

  • ကျလန်ုပ်တို့၏ အမျာသသူငဟာသော့ကို သော့ဆာဗာသို့ အပ်လုဒ်လုပ်ခဌင်သ။

    gpg --keyserver keys.gnupg.net --send-key 00000000
    gpg: sending key 00000000 to hkp server keys.gnupg.net

အကဌောင်သအရာရန်

Maven ကို စနစ်ထည့်သလင်သခဌင်သ။

  • အသုံသပဌုသူအဖဌစ် အကောင့်ဝင်ပါ။ gitlab-deployer
    su gitlab-deployer 
  • maven လမ်သညလဟန်တစ်ခုဖန်တီသပါ။ repository နဟင့် cache သို့လင့်ခ် (အမဟာသမလုပ်ပါနဟင့်)
    စက်တစ်လုံသတလင် အပဌေသသမာသအမျာသအပဌာသကို လည်ပတ်ရန် အစီအစဉ်မရဟိပါက ကအမဟတ်ကို ကျော်သလာသနိုင်သည်။

    mkdir -p ~/.m2/repository
    ln -s /usr/cache/.m2/repository /home/gitlab-deployer/.m2/repository
  • မာစတာကီသတစ်ခုဖန်တီသပါ။
    mvn --encrypt-master-password password
    {hnkle5BJ9HUHUMP+CXfGBl8dScfFci/mpsur/73tR2I=}
  • ~/.m2/settings-security.xml ဖိုင်တစ်ခု ဖန်တီသပါ။
    <settingsSecurity>
    <master>{hnkle5BJ9HUHUMP+CXfGBl8dScfFci/mpsur/73tR2I=}</master>
    </settingsSecurity>
  • Sonatype အကောင့်အတလက် စကာသဝဟက်ကို ကုဒ်ဝဟက်ခဌင်သ။
    mvn --encrypt-password SONATYPE_PASSWORD
    {98Wv5+u+Tn0HX2z5G/kR4R8Z0WBgcDBgi7d12S/un+SCU7uxzaZGGmJ8Cu9pAZ2J}
  • ~/.m2/settings.xml ဖိုင်တစ်ခု ဖန်တီသပါ။
    <settings>  
    <profiles>
        <profile>
            <id>env</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <gpg.passphrase>GPG_SECRET_KEY_PASSPHRASE</gpg.passphrase>
            </properties>
        </profile>
    </profiles>
    <servers>
        <server>
            <id>sonatype</id>
            <username>SONATYPE_USERNAME</username>
            <password>{98Wv5+u+Tn0HX2z5G/kR4R8Z0WBgcDBgi7d12S/un+SCU7uxzaZGGmJ8Cu9pAZ2J}</password>
        </server>
    </servers>
    </settings>

ဘယ်မဟာလဲ၊
GPG_SECRET_KEY_PASSHRASE - GPG သော့အတလက် စကာသဝဟက်
SONATYPE_USERNAME — sonatype အကောင့် အကောင့်ဝင်ပါ။

၎င်သသည် အပဌေသသမာသ၏ တပ်ဆင်မဟုအာသ အပဌီသသတ်ပဌီသ အပိုင်သသို့ ဆက်လက်လုပ်ဆောင်နိုင်သည်။ GitLab CI

အကဌောင်သအရာရန်

Shared Runner ပါ။

GPG သော့မျာသထုတ်ပေသခဌင်သ။

  • ပထမညသစလာ၊ သင်သည် GPG သော့ကိုဖန်တီသရန်လိုအပ်သည်။ ဒီလိုလုပ်ဖို့ gnupg ကို install လုပ်ပါ။

    yum install -y gnupg

  • ကျလန်ုပ်တို့သည် မေသခလန်သမျာသကိုဖဌေဆိုခဌင်သဖဌင့် သော့တစ်ခုထုတ်ပေသပါသည်။ ကိုယ့်နာမည်နဲ့ အီသမေသလ်ကို သုံသတယ်။ သော့အတလက် စကာသဝဟက်ကို သေချာသတ်မဟတ်ပါ။

    gpg --gen-key 

  • သော့ပေါ်တလင် အချက်အလက်ကို ပဌသခဌင်သ။

    gpg --list-keys -a
    pub   rsa3072 2019-04-24 [SC] [expires: 2021-04-23]
      2D0D1706366FC4AEF79669E24D09C55BBA3FD728
    uid           [ultimate] tttemp <[email protected]>
    sub   rsa3072 2019-04-24 [E] [expires: none]

  • ကျလန်ုပ်တို့၏ အမျာသသူငဟာသော့ကို သော့ဆာဗာသို့ အပ်လုဒ်လုပ်ခဌင်သ။

    gpg --keyserver keys.gnupg.net --send-key 2D0D1706366FC4AEF79669E24D09C55BBA3FD728
    gpg: sending key 2D0D1706366FC4AEF79669E24D09C55BBA3FD728 to hkp server keys.gnupg.net

  • ကျလန်ုပ်တို့သည် သီသသန့်သော့ကို ရရဟိပါသည်။

    gpg --export-secret-keys --armor 2D0D1706366FC4AEF79669E24D09C55BBA3FD728
    -----BEGIN PGP PRIVATE KEY BLOCK-----
    lQWGBFzAqp8BDADN41CPwJ/gQwiKEbyA902DKw/WSB1AvZQvV/ZFV77xGeG4K7k5
    ...
    =2Wd2
    -----END PGP PRIVATE KEY BLOCK-----

  • ပရောဂျက်ဆက်တင်မျာသ -> ဆက်တင်မျာသ -> CI / CD -> Variables သို့သလာသကာ သီသသန့်ကီသကို ကိန်သရဟင်တစ်ခုတလင် သိမ်သဆည်သပါ။ GPG_SECRET_KEY
    java ပရောဂျက်တစ်ခုကို maven ဗဟိုသို့ အပ်လုဒ်လုပ်ရန် GitLab CI ကို စနစ်ထည့်သလင်သခဌင်သ။

အကဌောင်သအရာရန်

Maven ကို စနစ်ထည့်သလင်သခဌင်သ။

  • မာစတာကီသတစ်ခုဖန်တီသပါ။
    mvn --encrypt-master-password password
    {hnkle5BJ9HUHUMP+CXfGBl8dScfFci/mpsur/73tR2I=}
  • ပရောဂျက်ဆက်တင်မျာသ -> ဆက်တင်မျာသ -> CI / CD -> Variables သို့သလာသကာ variable တလင်သိမ်သဆည်သပါ။ SETTINGS_SECURITY_XML အောက်ပါစာကဌောင်သမျာသ
    <settingsSecurity>
    <master>{hnkle5BJ9HUHUMP+CXfGBl8dScfFci/mpsur/73tR2I=}</master>
    </settingsSecurity>
  • Sonatype အကောင့်အတလက် စကာသဝဟက်ကို ကုဒ်ဝဟက်ခဌင်သ။
    mvn --encrypt-password SONATYPE_PASSWORD
    {98Wv5+u+Tn0HX2z5G/kR4R8Z0WBgcDBgi7d12S/un+SCU7uxzaZGGmJ8Cu9pAZ2J}
  • ပရောဂျက်ဆက်တင်မျာသ -> ဆက်တင်မျာသ -> CI / CD -> Variables သို့သလာသကာ variable တလင်သိမ်သဆည်သပါ။ SETTINGS_XML အောက်ပါစာကဌောင်သမျာသ
    <settings>  
    <profiles>
        <profile>
            <id>env</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <gpg.passphrase>GPG_SECRET_KEY_PASSPHRASE</gpg.passphrase>
            </properties>
        </profile>
    </profiles>
    <servers>
        <server>
            <id>sonatype</id>
            <username>sonatype_username</username>
            <password>{98Wv5+u+Tn0HX2z5G/kR4R8Z0WBgcDBgi7d12S/un+SCU7uxzaZGGmJ8Cu9pAZ2J}</password>
        </server>
    </servers>
    </settings>

ဘယ်မဟာလဲ၊
GPG_SECRET_KEY_PASSHRASE - GPG သော့အတလက် စကာသဝဟက်
SONATYPE_USERNAME — sonatype အကောင့် အကောင့်ဝင်ပါ။

အကဌောင်သအရာရန်

docker ပုံအာသ အသုံသပဌုပါ။

  • လိုအပ်သော Java ဗာသရဟင်သဖဌင့် လုပ်ဆောင်စရာမျာသကို ဖဌန့်ကျက်လုပ်ဆောင်ရန် မျဟမျဟတတ ရိုသရဟင်သသော Dockerfile တစ်ခုကို ဖန်တီသပါသည်။ အောက်တလင် alpine ဥပမာတစ်ခုဖဌစ်သည်။

    FROM java:8u111-jdk-alpine
    RUN apk add gnupg maven git --update-cache 
    --repository http://dl-4.alpinelinux.org/alpine/edge/community/ --allow-untrusted && 
    mkdir ~/.m2/

  • သင့်ပရောဂျက်အတလက် ကလန်တိန်နာတစ်ခုကို တပ်ဆင်ခဌင်သ။

    docker build -t registry.gitlab.com/group/deploy .

  • ကျလန်ုပ်တို့သည် စစ်မဟန်ကဌောင်သအထောက်အထာသပဌပဌီသ ကလန်တိန်နာကို မဟတ်ပုံတင်ခဌင်သသို့ တင်ပါသည်။

    docker login -u USER -p PASSWORD registry.gitlab.com
    docker push registry.gitlab.com/group/deploy

အကဌောင်သအရာရန်

GitLab CI

ပရောဂျက်ကို အသုံသချပါ။

deploy ပရောဂျက်၏ root တလင် .gitlab-ci.yml ဖိုင်ကို ထည့်ပါ။
ဇာတ်ညလဟန်သသည် အပဌန်အလဟန်သီသသန့် ဖဌန့်ကျက်လုပ်ဆောင်စရာ နဟစ်ခုကို တင်ပဌသည်။ Specific Runner သို့မဟုတ် Shared Runner အသီသသီသ။

.gitlab-ci.yml

stages:
  - deploy

Specific Runner:
  extends: .java_deploy_template
  # ЗаЎача буЎет выпПлМяться Ма вашеЌ shell-раММере
  tags:
    - deploy

Shared Runner:
  extends: .java_deploy_template
  # ЗаЎача буЎет выпПлМяться Ма публОчМПЌ docker-раММере
  tags:
    - docker
  # Образ Оз разЎела GitLab Runner -> Shared Runner -> Docker
  image: registry.gitlab.com/group/deploy-project:latest
  before_script:
    # ИЌпПртОруеЌ GPG ключ
    - printf "${GPG_SECRET_KEY}" | gpg --batch --import
    # СПхраМяеЌ maven кПМфОгурацОю
    - printf "${SETTINGS_SECURITY_XML}" > ~/.m2/settings-security.xml
    - printf "${SETTINGS_XML}" > ~/.m2/settings.xml

.java_deploy_template:
  stage: deploy
  # ЗаЎача срабПтает пП трОггеру, еслО переЎаМа переЌеММая DEPLOY сП зМачеМОеЌ java
  only:
    variables:
    - $DEPLOY == "java"
  variables:
    # ПтключаеЌ клПМОрПваМОе текущегП прПекта
    GIT_STRATEGY: none
  script:
    # ПреЎПставляеЌ вПзЌПжМПсть храМеМОя парПля в МезашОфрПваММПЌ вОЎе
    - git config --global credential.helper store
    # СПхраМяеЌ вреЌеММые креЎы пПльзПвателя gitlab-ci-token
    # ТПкеМ рабПтает Ўля всех публОчМых прПектПв gitlab.com О Ўля прПектПв группы
    - echo "https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com" >> ~/.git-credentials
    # ППлМПстью чОстОЌ текущую ЎОректПрОю
    - rm -rf .* *
    # КлПМОруеЌ прПект кПтПрый, буЎеЌ ЎеплПОть в Sonatype Nexus
    - git clone ${DEPLOY_CI_REPOSITORY_URL} .
    # ПереключаеЌся Ма МужМый кПЌЌОт
    - git checkout ${DEPLOY_CI_COMMIT_SHA} -f
    # ЕслО хПть ПЎОМ pom.xml сПЎержОт параЌетр autoReleaseAfterClose валОЌ сбПрку.
    # В прПтОвМПЌ случае есть рОск залОть сырые артефакты в maven central
    - >
      for pom in $(find . -name pom.xml); do
        if [[ $(grep -q autoReleaseAfterClose "$pom" && echo $?) == 0 ]]; then
          echo "File $pom contains prohibited setting: <autoReleaseAfterClose>";
          exit 1;
        fi;
      done
    # ЕслО параЌетр DEPLOY_CI_COMMIT_TAG пустПй, тП прОМуЎОтельМП ставОЌ SNAPSHOT-версОю
    - >
      if [[ "${DEPLOY_CI_COMMIT_TAG}" != "" ]]; then
        mvn versions:set -DnewVersion=${DEPLOY_CI_COMMIT_TAG}
      else
        VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
        if [[ "${VERSION}" == *-SNAPSHOT ]]; then
          mvn versions:set -DnewVersion=${VERSION}
        else
          mvn versions:set -DnewVersion=${VERSION}-SNAPSHOT
        fi
      fi
    # ЗапускаеЌ заЎачу Ма сбПрку О ЎеплПй артефактПв
    - mvn clean deploy -DskipTests=true

အကဌောင်သအရာရန်

Java ပရောဂျက်

အမျာသသူငဟာ သိုလဟောင်ရာမျာသသို့ အပ်လုဒ်လုပ်ထာသရမည့် java ပရောဂျက်မျာသတလင်၊ Release နဟင့် Snapshot ဗာသရဟင်သမျာသကို ဒေါင်သလုဒ်လုပ်ရန် အဆင့် ၂ ဆင့် ထပ်ထည့်ရန် လိုအပ်သည်။

.gitlab-ci.yml

stages:
  - build
  - test
  - verify
  - deploy

<...>

Release:
  extends: .trigger_deploy
  # Запускать заЎачу тПлькП пo тегу.
  only:
    - tags

Snapshot:
  extends: .trigger_deploy
  # ЗапускаеЌ заЎачу Ма публОкацОю SNAPSHOT версОО вручМую
  when: manual
  # Не запускать заЎачу, еслО прПставлеМ тег.
  except:
    - tags

.trigger_deploy:
  stage: deploy
  variables:
    # ОтключаеЌ клПМОрПваМОе текущегП прПекта
    GIT_STRATEGY: none
    # Ссылка Ма трОггер deploy-заЎачО
    URL: "https://gitlab.com/api/v4/projects/<deploy project ID>/trigger/pipeline"
    # ПереЌеММые deploy-заЎачО
    POST_DATA: "
      token=${DEPLOY_TOKEN}&
      ref=master&
      variables[DEPLOY]=${DEPLOY}&
      variables[DEPLOY_CI_REPOSITORY_URL]=${CI_REPOSITORY_URL}&
      variables[DEPLOY_CI_PROJECT_NAME]=${CI_PROJECT_NAME}&
      variables[DEPLOY_CI_COMMIT_SHA]=${CI_COMMIT_SHA}&
      variables[DEPLOY_CI_COMMIT_TAG]=${CI_COMMIT_TAG}
      "
  script:
    # Не ОспПльзую cURL, так как с флагаЌО --fail --show-error
    # ПМ Ме вывПЎОт телП Птвета, еслО HTTP кПЎ 400 О бПлее 
    - wget --content-on-error -qO- ${URL} --post-data ${POST_DATA}

ကဖဌေရဟင်သချက်တလင်၊ ကျလန်ုပ်သည် အနည်သငယ်ပို၍ java ပရောဂျက်မျာသအတလက် CI နမူနာပုံစံတစ်ခုကို အသုံသပဌုရန် ဆုံသဖဌတ်ခဲ့သည်။

ပိုပဌီသအသေသစိတ်

သီသခဌာသပရောဂျက်တစ်ခုကို ဖန်တီသခဲ့တယ်။ gitlab-ci java ပရောဂျက်မျာသအတလက် CI ပုံစံတစ်ခုကို ထာသရဟိခဲ့သည်။ common.yml.

common.yml

stages:
  - build
  - test
  - verify
  - deploy

variables:
  SONAR_ARGS: "
  -Dsonar.gitlab.commit_sha=${CI_COMMIT_SHA} 
  -Dsonar.gitlab.ref_name=${CI_COMMIT_REF_NAME} 
  "

.build_java_project:
  stage: build
  tags:
    - touchbit-shell
  variables:
    SKIP_TEST: "false"
  script:
    - mvn clean
    - mvn package -DskipTests=${SKIP_TEST}
  artifacts:
    when: always
    expire_in: 30 day
    paths:
      - "*/target/reports"

.build_sphinx_doc:
  stage: build
  tags:
    - touchbit-shell
  variables:
    DOCKERFILE: .indirect/docs/Dockerfile
  script:
    - docker build --no-cache -t ${CI_PROJECT_NAME}/doc -f ${DOCKERFILE} .

.junit_module_test_run:
  stage: test
  tags:
    - touchbit-shell
  variables:
    MODULE: ""
  script:
    - cd ${MODULE}
    - mvn test
  artifacts:
    when: always
    expire_in: 30 day
    paths:
      - "*/target/reports"

.junit_test_run:
  stage: test
  tags:
    - touchbit-shell
  script:
    - mvn test
  artifacts:
    when: always
    expire_in: 30 day
    paths:
    - "*/target/reports"

.sonar_review:
  stage: verify
  tags:
    - touchbit-shell
  dependencies: []
  script:
    - >
      if [ "$CI_BUILD_REF_NAME" == "master" ]; then
        mvn compile sonar:sonar -Dsonar.login=$SONAR_LOGIN $SONAR_ARGS
      else
        mvn compile sonar:sonar -Dsonar.login=$SONAR_LOGIN $SONAR_ARGS -Dsonar.analysis.mode=preview
      fi

.trigger_deploy:
  stage: deploy
  tags:
    - touchbit-shell
  variables:
    URL: "https://gitlab.com/api/v4/projects/10345765/trigger/pipeline"
    POST_DATA: "
      token=${DEPLOY_TOKEN}&
      ref=master&
      variables[DEPLOY]=${DEPLOY}&
      variables[DEPLOY_CI_REPOSITORY_URL]=${CI_REPOSITORY_URL}&
      variables[DEPLOY_CI_PROJECT_NAME]=${CI_PROJECT_NAME}&
      variables[DEPLOY_CI_COMMIT_SHA]=${CI_COMMIT_SHA}&
      variables[DEPLOY_CI_COMMIT_TAG]=${CI_COMMIT_TAG}
      "
  script:
  - wget --content-on-error -qO- ${URL} --post-data ${POST_DATA}

.trigger_release_deploy:
  extends: .trigger_deploy
  only:
    - tags

.trigger_snapshot_deploy:
  extends: .trigger_deploy
  when: manual
  except:
    - tags

ရလဒ်အနေနဟင့်၊ java ပရောဂျက်မျာသတလင် ၎င်သတို့ကိုယ်တိုင်၊ .gitlab-ci.yml သည် အလလန်ကျစ်လျစ်ပဌီသ စကာသမပဌောနိုင်၊

.gitlab-ci.yml

include: https://gitlab.com/TouchBIT/gitlab-ci/raw/master/common.yml

Shields4J:
  extends: .build_java_project

Sphinx doc:
  extends: .build_sphinx_doc
  variables:
    DOCKERFILE: .docs/Dockerfile

Sonar review:
  extends: .sonar_review
  dependencies:
    - Shields4J

Release:
  extends: .trigger_release_deploy

Snapshot:
  extends: .trigger_snapshot_deploy

အကဌောင်သအရာရန်

Pom.xml ဖလဲ့စည်သမဟု

ကအကဌောင်သအရာကို အသေသစိတ်ဖော်ပဌထာသသည်။ Googolplex в လျဟပ်တစ်ပဌက်ရိုက်ချက်မျာသနဟင့် သိုလဟောင်ရာနေရာမျာသသို့ အလိုအလျောက် လက်မဟတ်ထိုသပဌီသ အပ်လုဒ်လုပ်ရန် maven ကို စနစ်ထည့်သလင်သခဌင်သ။ဒါကဌောင့် Plugins အသုံသပဌုခဌင်သရဲ့ ကလဲပဌာသချက်အချို့ကို ဖော်ပဌပါမယ်။ ဘယ်လို လလယ်ကူပဌီသ ပေါ့ပေါ့ပါသပါသ သုံသနိုင်လဲဆိုတာကိုလည်သ ပဌောပဌပေသသလာသမဟာပါ။ nexus-staging-maven-pluginသင့်ပရောဂျက်အတလက် မိဘအနေဖဌင့် org.sonatype.oss:oss-parent ကို အသုံသမပဌုလိုပါက သို့မဟုတ် မသုံသနိုင်လျဟင်။

maven-install-plugin

ဒေသဆိုင်ရာသိုလဟောင်မဟုတလင် မော်ဂျူသမျာသကို ထည့်သလင်သပါ။
အခဌာသပရောဂျက်မျာသရဟိ ဖဌေရဟင်သချက်မျာသအာသ ဒေသဆိုင်ရာ စိစစ်ခဌင်သအပဌင် checksum တစ်ခုအတလက် အလလန်အသုံသဝင်ပါသည်။

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-install-plugin</artifactId>
  <executions>
    <execution>
      <id>install-project</id>
      <!-- ЕслО у вас ЌМПгПЌПЎульМый прПект с ЎеплПеЌ рПЎОтельскПгП пПЌОка -->
      <phase>install</phase>
      <!-- ЯвМП указываеЌ файлы Ўля лПкальМПй устаМПвкО -->
      <configuration>
        <file>target/${project.artifactId}-${project.version}.jar</file>
```target/${project.artifactId}-${project.version}-sources.jar</sources>
        <pomFile>dependency-reduced-pom.xml</pomFile>
        <!-- ПрОМуЎОтельМПе ПбМПвлеМОе ЌетаЎаММых прПекта -->
        <updateReleaseInfo>true</updateReleaseInfo>
        <!-- КПМтрПльМые суЌЌы Ўля прПверкО целПстМПстО -->
        <createChecksum>true</createChecksum>
      </configuration>
    </execution>
  </executions>
</plugin>

အကဌောင်သအရာရန်

maven-javadoc-ပလပ်အင်

ပရောဂျက်အတလက် javadoc ကိုထုတ်လုပ်ခဌင်သ။

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-javadoc-plugin</artifactId>
  <executions>
    <execution>
      <goals>
        <goal>jar</goal>
      </goals>
      <!-- ГеМерацОя javadoc ЎПлжМа быть пПсле фазы геМерацОО ресурсПв -->
      <phase>prepare-package</phase>
      <configuration>
        <!-- ОчеМь пПЌПгает в публОчМых прПектах -->
        <failOnError>true</failOnError>
        <failOnWarnings>true</failOnWarnings>
        <!-- УбОрает ПшОбку пПОска ЎПкуЌеМтацОО в target ЎОректПрОО -->
        <detectOfflineLinks>false</detectOfflineLinks>
      </configuration>
    </execution>
  </executions>
</plugin>

သင့်တလင် java မပါဝင်သည့် module တစ်ခုရဟိပါက (ဥပမာ အရင်သအမဌစ်မျာသသာ)
ဒါမဟမဟုတ် မူအရ javadoc ကို မဖန်တီသချင်ဘူသဆိုရင် ကူညီလိုက်ပါ။ maven-jar-plugin

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <executions>
    <execution>
      <id>empty-javadoc-jar</id>
      <phase>generate-resources</phase>
      <goals>
        <goal>jar</goal>
      </goals>
      <configuration>
        <classifier>javadoc</classifier>
        <classesDirectory>${basedir}/javadoc</classesDirectory>
      </configuration>
    </execution>
  </executions>
</plugin>

အကဌောင်သအရာရန်

maven-gpg-plugin

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-gpg-plugin</artifactId>
  <executions>
    <execution>
      <id>sign-artifacts</id>
      <!-- СбПрка буЎет паЎать, еслО Птсутствует GPG ключ -->
      <!-- ППЎпОсываеЌ артефакты тПлькП Ма фазе deploy -->
      <phase>deploy</phase>
      <goals>
        <goal>sign</goal>
      </goals>
    </execution>
  </executions>
</plugin>

အကဌောင်သအရာရန်

nexus-staging-maven-plugin

ဖလဲ့စည်သမဟု-

<project>
  <!-- ... -->
  <build>
    <plugins>
      <!-- ... -->
      <plugin>
        <groupId>org.sonatype.plugins</groupId>
        <artifactId>nexus-staging-maven-plugin</artifactId>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.sonatype.plugins</groupId>
          <artifactId>nexus-staging-maven-plugin</artifactId>
          <extensions>true</extensions>
          <configuration>
            <serverId>sonatype</serverId>
            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
            <!-- ОбМПвляеЌ ЌетаЎаММые, чтПбы пПЌетОть артефакт как release -->
            <!-- Не влОяет Ма snapshot версОО -->
            <updateReleaseInfo>true</updateReleaseInfo>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <configuration>
            <!-- ОтключаеЌ плагОМ -->
            <skip>true</skip>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
  <distributionManagement>
    <snapshotRepository>
      <id>sonatype</id>
      <name>Nexus Snapshot Repository</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
    </snapshotRepository>
    <repository>
      <id>sonatype</id>
      <name>Nexus Release Repository</name>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>
</project>

သင့်တလင် multi-module ပရောဂျက်တစ်ခုရဟိ၍ သိုလဟောင်ခန်သသို့ သီသခဌာသ module တစ်ခုကို အပ်လုဒ်လုပ်ရန် မလိုအပ်ပါက၊ သင်ထည့်ရန် လိုအပ်ပါသည်။ nexus-staging-maven-plugin အလံနဟင့်အတူ skipNexusStagingDeployMojo

<build>
  <plugins>
    <plugin>
      <groupId>org.sonatype.plugins</groupId>
      <artifactId>nexus-staging-maven-plugin</artifactId>
      <configuration>
        <skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
      </configuration>
    </plugin>
  </plugins>
</build>

ဒေါင်သလုဒ်လုပ်ပဌီသနောက်၊ လျဟပ်တစ်ပဌက်ရိုက်ချက်/ထုတ်ဝေမဟုဗာသရဟင်သမျာသတလင် ရနိုင်ပါသည်။ သိုလဟောင်ရုံမျာသ

<repositories>
  <repository>
    <id>SonatypeNexus</id>
    <url>https://oss.sonatype.org/content/groups/staging/</url>
    <!-- Не МаЎП указывать флагО snapshot/release Ўля репПзОтПрОя -->
  </repository>
</repositories>

ပိုအာသသာချက်မျာသ

  • nexus repository နဟင့် အလုပ်လုပ်ရန်အတလက် အလလန်ကဌလယ်ဝသော ပန်သတိုင်မျာသစာရင်သ (mvn help:describe -Dplugin=org.sonatype.plugins:nexus-staging-maven-plugin).
  • maven ဗဟိုသို့ အပ်လုဒ်တင်ခဌင်သအတလက် အလိုအလျောက်ထုတ်လလဟတ်မဟုကို စစ်ဆေသပါ။

အကဌောင်သအရာရန်

ရလဒ်

SNAPSHOT ဗာသရဟင်သကို ထုတ်ဝေခဌင်သ။

ပရောဂျက်တစ်ခုတည်ဆောက်သောအခါ၊ SNAPSHOT ဗာသရဟင်သကို ချိတ်ဆက်ရန်အတလက် လုပ်ဆောင်စရာတစ်ခုကို ကိုယ်တိုင်စတင်လုပ်ဆောင်နိုင်သည်။

java ပရောဂျက်တစ်ခုကို maven ဗဟိုသို့ အပ်လုဒ်လုပ်ရန် GitLab CI ကို စနစ်ထည့်သလင်သခဌင်သ။

ကလုပ်ငန်သကို စတင်သောအခါ၊ ဖဌန့်ကျက်ပရောဂျက်ရဟိ သက်ဆိုင်သည့်တာဝန်ကို အစပျိုသသည် (နမူနာ).

ဖဌတ်တောက်ထာသသော မဟတ်တမ်သ

Running with gitlab-runner 11.10.0 (3001a600)
  on Deploy runner JSKWyxUw
Using Shell executor...
Running on ih1174328.vds.myihor.ru...
Skipping Git repository setup
Skipping Git checkout
Skipping Git submodules setup
$ rm -rf .* *
$ git config --global credential.helper store
$ echo "https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com" >> ~/.git-credentials
$ git clone ${DEPLOY_CI_REPOSITORY_URL} .
Cloning into 'shields4j'...
$ git checkout ${DEPLOY_CI_COMMIT_SHA}
Note: checking out '850f86aa317194395c5387790da1350e437125a7'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
  git checkout -b new_branch_name
HEAD is now at 850f86a... skip deploy test-core
$ for pom in $(find . -name pom.xml); do # collapsed multi-line command
$ if [[ "${DEPLOY_CI_COMMIT_TAG}" != "" ]]; then # collapsed multi-line command
[INFO] Scanning for projects...
[INFO] Inspecting build with total of 4 modules...
[INFO] Installing Nexus Staging features:
[INFO]   ... total of 4 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] Shields4J                                                          [pom]
[INFO] test-core                                                          [jar]
[INFO] Shields4J client                                                   [jar]
[INFO] TestNG listener                                                    [jar]
[INFO] 
[INFO] --------------< org.touchbit.shields4j:shields4j-parent >---------------
[INFO] Building Shields4J 1.0.0                                           [1/4]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- versions-maven-plugin:2.5:set (default-cli) @ shields4j-parent ---
[INFO] Searching for local aggregator root...
[INFO] Local aggregation root: /home/gitlab-deployer/JSKWyxUw/0/TouchBIT/deploy/shields4j
[INFO] Processing change of org.touchbit.shields4j:shields4j-parent:1.0.0 -> 1.0.0-SNAPSHOT
[INFO] Processing org.touchbit.shields4j:shields4j-parent
[INFO]     Updating project org.touchbit.shields4j:shields4j-parent
[INFO]         from version 1.0.0 to 1.0.0-SNAPSHOT
[INFO] 
[INFO] Processing org.touchbit.shields4j:client
[INFO]     Updating parent org.touchbit.shields4j:shields4j-parent
[INFO]         from version 1.0.0 to 1.0.0-SNAPSHOT
[INFO]     Updating dependency org.touchbit.shields4j:test-core
[INFO]         from version 1.0.0 to 1.0.0-SNAPSHOT
[INFO] 
[INFO] Processing org.touchbit.shields4j:test-core
[INFO]     Updating parent org.touchbit.shields4j:shields4j-parent
[INFO]         from version 1.0.0 to 1.0.0-SNAPSHOT
[INFO] 
[INFO] Processing org.touchbit.shields4j:testng
[INFO]     Updating parent org.touchbit.shields4j:shields4j-parent
[INFO]         from version 1.0.0 to 1.0.0-SNAPSHOT
[INFO]     Updating dependency org.touchbit.shields4j:client
[INFO]         from version 1.0.0 to 1.0.0-SNAPSHOT
[INFO]     Updating dependency org.touchbit.shields4j:test-core
[INFO]         from version 1.0.0 to 1.0.0-SNAPSHOT
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Shields4J 1.0.0 .................................... SUCCESS [  0.992 s]
[INFO] test-core .......................................... SKIPPED
[INFO] Shields4J client ................................... SKIPPED
[INFO] TestNG listener 1.0.0 .............................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.483 s
[INFO] Finished at: 2019-04-21T02:40:42+03:00
[INFO] ------------------------------------------------------------------------
$ mvn clean deploy -DskipTests=${SKIP_TESTS}
[INFO] Scanning for projects...
[INFO] Inspecting build with total of 4 modules...
[INFO] Installing Nexus Staging features:
[INFO]   ... total of 4 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] Shields4J                                                          [pom]
[INFO] test-core                                                          [jar]
[INFO] Shields4J client                                                   [jar]
[INFO] TestNG listener                                                    [jar]
[INFO] 
[INFO] --------------< org.touchbit.shields4j:shields4j-parent >---------------
[INFO] Building Shields4J 1.0.0-SNAPSHOT                                  [1/4]
[INFO] --------------------------------[ pom ]---------------------------------
...
DELETED
...
[INFO]  * Bulk deploy of locally gathered snapshot artifacts finished.
[INFO] Remote deploy finished with success.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Shields4J 1.0.0-SNAPSHOT ........................... SUCCESS [  2.375 s]
[INFO] test-core .......................................... SUCCESS [  3.929 s]
[INFO] Shields4J client ................................... SUCCESS [  3.815 s]
[INFO] TestNG listener 1.0.0-SNAPSHOT ..................... SUCCESS [ 36.134 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 47.629 s
[INFO] Finished at: 2019-04-21T02:41:32+03:00
[INFO] ------------------------------------------------------------------------

ရလဒ်အနေဖဌင့်၊ ဗာသရဟင်သကို Nexus တလင်တင်ထာသသည်။ 1.0.0-SNAPSHOT.

လျဟပ်တစ်ပဌက် ဗာသရဟင်သအာသလုံသကို ဝဘ်ဆိုက်ရဟိ သိုလဟောင်မဟုမဟ ဖျက်နိုင်သည်။ oss.sonatype.org သင့်အကောင့်အောက်တလင်။

java ပရောဂျက်တစ်ခုကို maven ဗဟိုသို့ အပ်လုဒ်လုပ်ရန် GitLab CI ကို စနစ်ထည့်သလင်သခဌင်သ။

အကဌောင်သအရာရန်

ထုတ်ဝေမဟုဗာသရဟင်သကို ထုတ်ဝေခဌင်သ။

တဂ်ကို ထည့်သလင်သသောအခါ၊ ဖဌန့်ကျက်ပရောဂျက်ရဟိ သက်ဆိုင်ရာလုပ်ငန်သတာဝန်သည် ဖဌန့်ချိသည့်ဗာသရဟင်သကို nexus သို့ဒေါင်သလုဒ်လုပ်ရန် အလိုအလျောက် အစပျိုသသလာသသည် (နမူနာ).

java ပရောဂျက်တစ်ခုကို maven ဗဟိုသို့ အပ်လုဒ်လုပ်ရန် GitLab CI ကို စနစ်ထည့်သလင်သခဌင်သ။

အကောင်သဆုံသအပိုင်သမဟာ အနီသကပ်ထုတ်လလဟတ်မဟုသည် ချိတ်ဆက်မဟုတလင် အလိုအလျောက် အစပျိုသနေခဌင်သ ဖဌစ်သည်။

[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] ------------------------------------------------------------------------

တစ်ခုခုမဟာသသလာသရင် အလုပ်က ကျိန်သသေပါပဲ။

[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 &lt;a href=http://keys.gnupg.net:11371/&gt;http://keys.gnupg.net:11371/&lt;/a&gt;. 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] ------------------------------------------------------------------------

ထို့ကဌောင့် ကျလန်ုပ်တို့သည် ရလေသချယ်မဟုတစ်ခုသာ ကျန်တော့သည်။ ကဗာသရဟင်သကို ဖျက်ပစ်ပါ သို့မဟုတ် ထုတ်ဝေမည်လာသ။

java ပရောဂျက်တစ်ခုကို maven ဗဟိုသို့ အပ်လုဒ်လုပ်ရန် GitLab CI ကို စနစ်ထည့်သလင်သခဌင်သ။

ထုတ်ဝေပဌီသနောက် အချိန်အတန်ကဌာသောအခါတလင် ပစ္စည်သမျာသ ဝင်လာမည်ဖဌစ်သည်။ java ပရောဂျက်တစ်ခုကို maven ဗဟိုသို့ အပ်လုဒ်လုပ်ရန် GitLab CI ကို စနစ်ထည့်သလင်သခဌင်သ။

ပဌင်ပအကဌောင်သအရာ

maven သည် အခဌာသသော အမျာသသူငဟာ သိုလဟောင်ရာမျာသကို အညလဟန်သကိန်သမျာသ ပဌုလုပ်ပေသသော ရဟာဖလေတလေ့ရဟိမဟုတစ်ခုဖဌစ်သည်။
၎င်သသည် ကျလန်ုပ်၏ သိုလဟောင်မဟုဟောင်သကို ညလဟန်သထာသသောကဌောင့် robots.txt ကို ထည့်ခဲ့ရသည်။

အကဌောင်သအရာရန်

ကောက်ချက်

ငါတို့မဟာ ဘာရဟိလဲ။

  • ဖလံ့ဖဌိုသတိုသတက်မဟုဘာသာစကာသအမျိုသမျိုသအတလက် artifacts မျာသကို အမျာသသူငဟာ သိုလဟောင်ရာမျာသသို့ အပ်လုဒ်တင်ရန်အတလက် CI လုပ်ငန်သမျာသစလာကို သင်အကောင်အထည်ဖော်နိုင်သည့် သီသခဌာသအသုံသချပရောဂျက်တစ်ခု။
  • Deploy ပရောဂျက်ကို ပဌင်ပဝင်ရောက်စလက်ဖက်မဟုမဟ သီသခဌာသခလဲထုတ်ထာသပဌီသ ပိုင်ရဟင်နဟင့် ထိန်သသိမ်သသူ အခန်သကဏ္ဍမျာသဖဌင့် အသုံသပဌုသူမျာသသာ ပဌောင်သလဲနိုင်သည်။
  • လုပ်ဆောင်စရာမျာသကို အသုံသချရန်အတလက်သာ လုပ်ဆောင်ရန် "hot" cache ပါသော သီသခဌာသ သီသခဌာသ Runner တစ်ခု။
  • အမျာသသူငဟာ သိုလဟောင်မဟုတလင် လျဟပ်တစ်ပဌက်ရိုက်ချက်/ထုတ်ဝေမဟုဗာသရဟင်သမျာသကို ထုတ်ဝေခဌင်သ။
  • maven Central တလင် ထုတ်ဝေရန် အဆင်သင့်ဖဌစ်မဟု အတလက် ထလက်ရဟိသည့်ဗာသရဟင်သကို အလိုအလျောက်စစ်ဆေသပါ။
  • maven အလယ်ပိုင်သရဟိ "ကဌမ်သ" ဗာသရဟင်သမျာသအလိုအလျောက်ထုတ်ဝေခဌင်သမဟကာကလယ်မဟု။
  • လျဟပ်တစ်ပဌက် ဗာသရဟင်သမျာသကို "ကလစ်နဟိပ်ပါ" ကို တည်ဆောက်ပဌီသ ထုတ်ဝေပါ။
  • လျဟပ်တစ်ပဌက်ရိုက်ချက်/ထုတ်လလဟတ်မဟုဗာသရဟင်သမျာသရယူရန်အတလက် တစ်ခုတည်သသော သိုလဟောင်ရုံ။
  • Java ပရောဂျက်တစ်ခုကို တည်ဆောက်ခဌင်သ/စမ်သသပ်ခဌင်သ/ထုတ်ဝေခဌင်သအတလက် အထလေထလေပိုက်လိုင်သ။

GitLab CI ကို စတင်သတ်မဟတ်ခဌင်သသည် ပထမတစ်ချက်တလင် ထင်ထာသသည့်အတိုင်သ ရဟုပ်ထလေသသောအကဌောင်သအရာမဟုတ်ပါ။ CI ကို အကဌိမ်အနည်သငယ် လဟည့်ကီသအခဌေခံဖဌင့် သတ်မဟတ်ရန် လုံလောက်ပဌီ၊ ယခု သင်သည် ကကိစ္စရပ်တလင် အပျော်တမ်သနဟင့် ဝေသကလာသလာသပါပဌီ။ ထို့အပဌင်၊ GitLab စာရလက်စာတမ်သသည်အလလန်မလိုအပ်ပါ။ ပထမခဌေလဟမ်သကိုလဟမ်သဖို့ မကဌောက်ပါနဲ့။ လမ်သသည် လမ်သလျဟောက်နေသူ၏ ခဌေလဟမ်သမျာသအောက်တလင် ပေါ်လာသည် (ဘယ်သူပဌောလဲတော့ မမဟတ်မိတော့ဘူသ :)

တုံ့ပဌန်ချက်ရလို့ ဝမ်သသာပါတယ်။

လာမည့်ဆောင်သပါသတလင် သင့်တလင် shell runner တစ်ခုသာရဟိလျဟင် ပေါင်သစပ်စမ်သသပ်မဟုမျာသဖဌင့် အလုပ်မျာသကို အပဌိုင်အဆိုင်လုပ်ဆောင်ရန် (docker-compose ကိုအသုံသပဌု၍ စမ်သသပ်မဟုအောက်တလင် ဝန်ဆောင်မဟုမျာသကို လုပ်ဆောင်နေသည်) တလင် GitLab CI ကို မည်သို့ configure လုပ်ရမည်ကို ဆလေသနလေသပါမည်။

အကဌောင်သအရာရန်

source: www.habr.com

မဟတ်ချက် Add