GoogleCloudPlatform / app-gradle-plugin

The library has moved to https://github.com/GoogleCloudPlatform/appengine-plugins/tree/main/app-gradle-plugin

Home Page:https://cloud.google.com/appengine/docs/standard/java/tools/gradle-reference

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

is it possible change app.yml to custom app.yml depends on my ENVIRONMENT?

matheusfrancisco opened this issue · comments

I don't know if this is possible but I'm trying to run appengineDeploy and sometimes build from app-env-stage.yml and sometimes app.yml. I did this on .kts file.

appengine {
    stage.setArtifact("build/libs/${project.name}-${project.version}-all.jar")

    val env = System.getenv("ENVIRONMENT") ?: "local"
    deploy {
        projectId = "GCLOUD_CONFIG"
        version = "GCLOUD_CONFIG"
        val path = when(env) {
           "production" -> "$projectDir/src/main/appengine/prod"
            "staging" -> "$projectDir/src/main/appengine/staging"
            else -> "$projectDir/src/main/appengine/local"
        }
        setAppEngineDirectory(path)
    }
}

but when I run appengineDeploy it tries to get from appengine/app.yml, not from the env I passed.

just don't know if is the best way but I figure it out I don´t know if I had to change only on stage.

    deploy {
        projectId = "GCLOUD_CONFIG"
        version = "GCLOUD_CONFIG"
        setAppEngineDirectory(
            when(System.getenv("ENVIRONMENT") ?: "local") {
                "production" -> "$projectDir/src/main/appengine/prod"
                "staging" -> "$projectDir/src/main/appengine/staging"
                else -> "$projectDir/src/main/appengine/local"
            }
        )
    }
    stage {
        setAppEngineDirectory(
            when(System.getenv("ENVIRONMENT") ?: "local") {
                "production" -> "$projectDir/src/main/appengine/prod"
                "staging" -> "$projectDir/src/main/appengine/staging"
                else -> "$projectDir/src/main/appengine/local"
            }
        )
    }

I understood just the stage worked

   stage {
        setAppEngineDirectory(
            when(System.getenv("ENVIRONMENT") ?: "local") {
                "production" -> "$projectDir/src/main/appengine/prod"
                "staging" -> "$projectDir/src/main/appengine/staging"
                else -> "$projectDir/src/main/appengine/local"
            }
        )
    }