pipeline {
  agent any
  stages {
    stage('检出') {
      steps {
        checkout([$class: 'GitSCM',
        branches: [[name: GIT_BUILD_REF]],
        userRemoteConfigs: [[
          url: GIT_REPO_URL,
          credentialsId: CREDENTIALS_ID
        ]]])
      }
    }
    stage('编译构建') {
      agent {
        docker {
          reuseNode 'true'
          registryUrl 'https://coding-public-docker.pkg.coding.net'
          image 'public/docker/android:29'
        }

      }
      post {
        always {
          sh './gradlew assembleDebug'

        }

      }
      steps {
        sh './gradlew clean && rm -rf ./app/build/'
      }
    }
    stage('上传到 Generic') {
      steps {
        codingArtifactsGeneric(credentialsId: "${CODING_ARTIFACTS_CREDENTIALS_ID}", withBuildProps: true, files: 'app/build/outputs/apk/**/*.apk', repoName: "${GENERIC_REPO_NAME}", version: "${CI_BUILD_NUMBER}")
      }
    }
  }
}