Error Gradle with BigQuery account

Hi community,

I had a very serious error with gradle because gradle used an other bigquery account.

I encountered this error :

Error executing BigQuery query: Access Denied: Project compte-nickel-datastg: User does not have permission in project compte-nickel-datastg.

We investigated with the Bigquery team at my company and they tell me that Gradle sends the “compte-nickel-dataprod” account instead of sending “compte-nickel-dataprod”.

So, Gradle use “compte-nickel-dataprod” but does not use the “compte-nickel-dataprod” account.

In my java code, i have just this line and it’s work on my personal computer :

package Keywords


public class BigQueryReadData {
	private static final String projectid = "compte-nickel-datastg";
	private static final String tableid = "RAW_qualif_eco_sepa";
	private static final String datasetid = "KAFKA";
	private static final String file_path = "C:\\Users\\soukna\\Katalon Studio\\BG\\BG_secret3.json";
	//private static final String file_path = "C:\\Users\\soukna\\Katalon Studio\\BG\\BG_secret.json";

	public static void main(String[] args) {
		System.setProperty("GOOGLE_APPLICATION_CREDENTIALS", file_path);
		BigQuery bigQuery = BigQueryOptions.getDefaultInstance().getService();
		String query = String.format("SELECT * FROM `%s.%s.%s` LIMIT 5;", projectid, datasetid, tableid);
		QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(query).build();
		try {
			TableResult result = bigQuery.query(queryConfig);
			for ( row : result.iterateAll()) {
		} catch (Exception e) {
			System.err.println("Error executing BigQuery query: " + e.getMessage());

So, I repeat that Gradle use “compte-nickel-dataprod” account and I wish to set up Gradle to use the “compte-nickel-datastg” account.

Someone can help me please ?

This is my Build.gradle :

plugins {
    id 'groovy'

group = 'org.example'
version = '1.0-SNAPSHOT'

repositories {

dependencies {
    implementation 'org.apache.groovy:groovy:4.0.2'
    implementation ''
    implementation ''


sourceSets {
    main {
        groovy {
            srcDirs = ['Keywords'] // Add the 'Keywords' folder here

test {

tasks.register('run', JavaExec) {
    mainClass = 'Keywords.BigQueryReadData'
    classpath = sourceSets.main.runtimeClasspath + files('Keywords')

Thank u

I’m not sure how this question is in any way Gradle related.
You say you want “Gradle to use a different account”, but Gradle does not use any account for anything anyway.
Your code is using some account for something.

Without knowing what BigQuery actually is, I just guess, that you either have to set that account from your code, or set some system property of environment variable. If one of the latter, you could do that for example in the configuration of your JavaExec task.

How to configure on my JavaExec task please ?

Configure what on the task?