diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..f33b7c77 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: CI Build and Test # Action 的名称 + +on: + push: + branches: [ main ] # 触发条件:推送代码到 main 分支时运行 + pull_request: + branches: [ main ] # 触发条件:向 main 分支提 PR 时运行 + +jobs: + build: # 任务名称(自定义) + runs-on: ubuntu-latest # 运行环境(可选:ubuntu-latest, windows-latest, macos-latest) + + steps: + - name: Checkout code # 步骤1:拉取代码 + uses: actions/checkout@v4 + + - name: Setup Node.js # 步骤2:安装 Node.js(示例) + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Install dependencies # 步骤3:安装依赖 + run: npm install + + - name: Run tests # 步骤4:运行测试 + run: npm test \ No newline at end of file diff --git a/README.md b/README.md index 183b6f43..58d3c8be 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# AndroidStudy +# AndroidStudy 111 222 333 # 扫描二维码下载APK示例:  diff --git a/app/build.gradle b/app/build.gradle index 2b701d0f..4a925817 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'com.android.application' -//获取时间戳 +//获取时间戳 交付pipeline def getDate() { def date = new Date() def formattedDate = date.format('yyyyMMddHHmm') diff --git a/app/src/androidTest/java/org/ninetripods/mq/study/ExampleInstrumentedTest.java b/app/src/androidTest/java/org/ninetripods/mq/study/ExampleInstrumentedTest.java index 4c43572e..66bf7236 100644 --- a/app/src/androidTest/java/org/ninetripods/mq/study/ExampleInstrumentedTest.java +++ b/app/src/androidTest/java/org/ninetripods/mq/study/ExampleInstrumentedTest.java @@ -18,7 +18,7 @@ public class ExampleInstrumentedTest { @Test public void useAppContext() throws Exception { - // Context of the app under test. + // Context of the app under test. test 流水线 00 Context appContext = InstrumentationRegistry.getTargetContext(); assertEquals("org.ninetripods.mq.circleview", appContext.getPackageName()); diff --git a/jenkinsfile b/jenkinsfile new file mode 100644 index 00000000..14ea4943 --- /dev/null +++ b/jenkinsfile @@ -0,0 +1,44 @@ +pipeline { + agent any + + stages { + stage('Checkout') { + steps { + checkout([$class: 'GitSCM', + branches: [[name: '*/main']], + userRemoteConfigs: [[url: 'https://github.com/username/my-android-app.git']]]) + } + } + + stage('Build') { + steps { + sh './gradlew assembleDebug' + } + } + + stage('Test') { + steps { + sh './gradlew test' + } + } + + stage('Lint') { + steps { + sh './gradlew lint' + } + } + + stage('Publish') { + steps { + sh './gradlew assembleRelease' + archiveArtifacts artifacts: 'app/build/outputs/apk/release/*.apk', fingerprint: true + } + } + } + + post { + always { + cleanWs() + } + } +}