My team is starting to migrate from Jenkins over to Gitlab. I was tasked with converting the Jenkinsfiles to .gitlab-ci.yml. I am new to using Gitlab so I am still not very clear on how some things translate from Jenkins to Gitlab. Below I have a snippet of the Jenkinsfile:
stages {
stage(“Unit Test”) {
agent {
docker {
image ‘maven:3.6.3-jdk-8’
}
}
steps {
configFileProvider([configFile(fileId: ‘project-maven-settings’, variable: ‘MAVEN_SETTINGS_XML’)]) {
sh ‘mvn -s $MAVEN_SETTINGS_XML clean test -P project’
}
}
}
When it comes to translating this to gitlab-ci, I am confused about the following:
- How do I set the agent within the stage?
- How does configFileProvider (a Jenkins plugin that allows me to copy over config files) translate to gitlab-ci.
This is what I have so far:
job “Unit Test”:
stage: test
script:
- sh ‘mvn -s $MAVEN_SETTINGS_XML clean test -P project’