Livaco
Livaco

Reputation: 56

Gitlab CI Not backgrounding JAR file on deploy stage

I've got a java project I want to implement Gitlab CI into. Everytime I make a commit, I want it to compile the jar (via maven) and then start it on my VPS, and keep it running until the next commit where I update it, ect.

I've tried to do this, but I can't get the deploy stage right. It runs the Jar file, but it runs it as part of the pipeline, instead of backgrounding it, and running it on the VPS.

My .gitlab-ci.yml:

image: maven:3-jdk-8

compile:
    stage: build
    script:
        - "pwd"
        - "mvn compile assembly:single"

deploy:
    stage: deploy
    script:
        - "nohup java -jar target/botaco_rewrite-1.0.0-jar-with-dependencies.jar dev.livaco.botaco_rewrite.Botaco &"

Upvotes: 2

Views: 1488

Answers (2)

Livaco
Livaco

Reputation: 56

Fixed this by simply moving to CentOS.

Upvotes: 1

Shmuel
Shmuel

Reputation: 1668

It's looks from this line image: maven:3-jdk-8
like you running the job inside a docker container so when the job is done the container is destroyed and all the running process are killed with it.

You should either run the job on the host directly (assuming you running your own gitlab runner)
or better to my opinion copy the jar file to another machine and run it there.

P.S. (you probably want to upload the jar to some artifact repository.)

Upvotes: 1

Related Questions