Pass a file to Gitlab pipeline job before execution

Viewed 348

I have a Gitlab project using Docker as the runner with the below yaml.

image: maven:3.3.9-jdk-8

build:
  stage: build
  script:
    - mvn compile

test:
  stage: test
  script:
    - mvn test -DsuiteFile=$testName

I am passing 'testName' as a variable for a manual pipeline job as shown below. I also have a payload test data input file within the Gitlab repo which is currently used by my tests. My new requirement is to remove the excel from the repo and pass this excel file dynamically as a variable just before I execute the job so that anyone can change test data without making code changes.

I don't know if we can pass the file as a variable as shown in the screenshot and make it readable to code during runtime. Posting this question to understand different ways of doing this. Any method that allows any user with Gitlab access to manipulate the excel file just before running the job will help.

Gitlab runner and docker will be used in AWS EC2 later so AWS related solutions will also help.

enter image description here

Current implementation of file loading within the project:

public ExcelControlCenter(String sheetname)
        {
            try 
            {
                fileLocation = System.getProperty("user.dir");
                logger.info("Loading excel. "+fileLocation);
                location = new File(fileLocation+"/payload/OpAccount.xlsx");
                fileStream = new FileInputStream(location);
                workBook = new XSSFWorkbook(fileStream);
                sheetName = workBook.getSheet(sheetname);
                System.out.println("Excel Loaded.");
            } 
0 Answers
Related