Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Tryb ciągłej integracji (CI) to sposób tworzenia oprogramowania, w którym deweloperzy często scalają zmiany kodu w centralne repozytorium, po którym uruchamiają się automatyczne kompilacje i testy.
Możesz skonfigurować podstawowy system CI, aby zapobiec nowym zmianom, które zaburzą kompilację po scaleniu. Możesz zaprogramować bardziej zaawansowany system CI, który będzie automatycznie testować aplikację i dbać o to, aby działała zgodnie z oczekiwaniami w różnych środowiskach, takich jak poziomy interfejsów API, rozmiary ekranu i platformy.
Rysunek 1. System CI utrzymuje prawidłowe repozytorium kodu przez przeprowadzanie kontroli przed scaleniem.
W tym dokumencie omawiamy typowe strategie stosowane przez deweloperów do konfigurowania skutecznych systemów CI na potrzeby projektów Androida. Wytyczne te mają charakter ogólny
i dotyczą większości rozwiązań.
Typowy przykład
Typowy system CI korzysta z przepływu pracy lub potoku, który może wyglądać tak:
System CI wykrywa zmianę w kodzie, zwykle w momencie, gdy programista tworzy żądanie pull, zwane także „listą zmian” lub „żądaniem scalenia”.
Udostępnia i inicjuje serwer, który uruchamia przepływ pracy.
W razie potrzeby pobiera kod i narzędzia takie jak pakiet Android SDK lub obrazy emulatora.
Kompiluje projekt, uruchamiając podane polecenie, na przykład ./gradlew
build.
Uruchamia testy lokalne, wykonując określone polecenie, na przykład uruchomienie /gradlew test.
Przesyła artefakty, takie jak wyniki testów i pliki APK.
Rysunek 2. Podstawowy przepływ pracy CI
Zalety CI
Zalety CI:
Lepsza jakość oprogramowania: CI może pomóc w polepszaniu jakości oprogramowania przez wykrywanie i rozwiązywanie problemów na wczesnym etapie. Pomaga to zmniejszyć liczbę błędów w wersjach oprogramowania i poprawić ogólny komfort użytkowników.
Mniejsze ryzyko uszkodzenia kompilacji: gdy automatyzujesz proces kompilacji za pomocą CI, możesz lepiej unikać uszkodzonych kompilacji, rozwiązując problemy na wcześniejszym etapie tego procesu.
Większe zaufanie do wersji: CI pomaga zadbać o to, aby każda wersja była stabilna i gotowa do wdrożenia w środowisku produkcyjnym. Prowadząc testy automatyczne, CI może wykryć potencjalne problemy, zanim je opublikujesz.
Ulepszona komunikacja i współpraca: zapewniając programistom centralne miejsce do udostępniania kodu i wyników testów, CI ułatwia programistom i innym członkom zespołu współpracę i śledzenie postępów.
Większa produktywność: CI może pomóc w zwiększeniu produktywności programistów przez automatyzację zadań, które w innym przypadku byłyby czasochłonne i podatne na błędy.
Więcej materiałów
Więcej informacji o tym, jak korzystać ze stałej integracji do ulepszania aplikacji, znajdziesz na tych stronach:
Treść strony i umieszczone na niej fragmenty kodu podlegają licencjom opisanym w Licencji na treści. Java i OpenJDK są znakami towarowymi lub zastrzeżonymi znakami towarowymi należącymi do firmy Oracle lub jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-27 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-07-27 UTC."],[],[],null,["# Continuous Integration basics\n\nContinuous Integration (CI) is a software development practice where developers\nfrequently merge their code changes into a central repository, after which\nautomated builds and tests run.\n\nYou can set up a basic CI system to prevent new changes that would break the\nbuild after merging in. You can program a more advanced CI system to\nautomatically test the app and make sure it behaves as expected in different\nenvironments, such as API levels, screen sizes, and platforms.\n**Figure 1.** A CI system keeps a code repository healthy by running checks before merging.\n\nThis document demonstrates common strategies developers use to set up effective\nCI systems for Android projects. These guidelines are generic and apply to the\nmajority of solutions.\n\nTypical example\n---------------\n\nA typical CI system follows a *workflow* or *pipeline*, which might look as\nfollows:\n\n1. The CI system detects a change in the code, usually when a developer creates a pull request, also called \"change list\" or \"merge request\".\n2. It provisions and initializes a server to run the workflow.\n3. It fetches the code as well as tools such as the Android SDK or emulator images if needed.\n4. It builds the project by running a given command, for example .`/gradlew\n build`.\n5. It runs the [local tests](/training/testing/local-tests) by running a given command, for example running .`/gradlew test`.\n6. It starts emulators and runs the [instrumented tests](/training/testing/instrumented-tests).\n7. It uploads artifacts such as test results and APKs.\n\n**Figure 2.** A basic CI workflow\n\nBenefits of CI\n--------------\n\nThe advantages of CI include:\n\n- **Improved quality of software**: CI can help to improve the quality of software by identifying and fixing problems early on. This can help to reduce the number of bugs in software releases and improve the overall user experience.\n- **Reduced risk of broken builds**: When you automate your build process with CI you can better avoid broken builds by resolving issues earlier in the process.\n- **Increased confidence in releases**: CI can help to ensure that each release is stable and ready for production. By running automated tests, CI can identify any potential problems before you release them to the public.\n- **Improved communication and collaboration**: By providing a central place for developers to share code and test results, CI can help to make it easier for developers and other team members to work together and track progress.\n- **Increased productivity**: CI can help to increase developer productivity by automating tasks that would otherwise be time-consuming and error-prone.\n\nFurther reading\n---------------\n\nMore more information on how you can use constant integration to improve\ndevelopment for your app, read the following pages:\n\n- **[CI Automation](/training/testing/continuous-integration/automation)**\n\n- **[CI Features](/training/testing/continuous-integration/features)**"]]