Commit 4cfb1d42 authored by Sofia Vistas's avatar Sofia Vistas Committed by Dan Davison

Add upload and download of Maven package via CI

parent a1f33b7b
...@@ -22,10 +22,22 @@ module QA ...@@ -22,10 +22,22 @@ module QA
end end
end end
it 'publishes a maven package and deletes it', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/943' do let!(:runner) do
Resource::Runner.fabricate! do |runner|
runner.name = "qa-runner-#{Time.now.to_i}"
runner.tags = ["runner-for-#{project.name}"]
runner.executor = :docker
runner.project = project
end
end
let!(:gitlab_address_with_port) do
uri = URI.parse(Runtime::Scenario.gitlab_address) uri = URI.parse(Runtime::Scenario.gitlab_address)
gitlab_address_with_port = "#{uri.scheme}://#{uri.host}:#{uri.port}" "#{uri.scheme}://#{uri.host}:#{uri.port}"
pom_xml = { end
let(:pom_xml) do
{
file_path: 'pom.xml', file_path: 'pom.xml',
content: <<~XML content: <<~XML
<project> <project>
...@@ -52,28 +64,33 @@ module QA ...@@ -52,28 +64,33 @@ module QA
</project> </project>
XML XML
} }
settings_xml = { end
let(:settings_xml) do
{
file_path: 'settings.xml', file_path: 'settings.xml',
content: <<~XML content: <<~XML
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"> xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<servers> <servers>
<server> <server>
<id>#{project.name}</id> <id>#{project.name}</id>
<configuration> <configuration>
<httpHeaders> <httpHeaders>
<property> <property>
<name>Private-Token</name> <name>Private-Token</name>
<value>#{auth_token}</value> <value>#{auth_token}</value>
</property> </property>
</httpHeaders> </httpHeaders>
</configuration> </configuration>
</server> </server>
</servers> </servers>
</settings> </settings>
XML XML
} }
end
it 'publishes a maven package and deletes it', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/943' do
# Use a maven docker container to deploy the package # Use a maven docker container to deploy the package
with_fixtures([pom_xml, settings_xml]) do |dir| with_fixtures([pom_xml, settings_xml]) do |dir|
Service::DockerRun::Maven.new(dir).publish! Service::DockerRun::Maven.new(dir).publish!
...@@ -99,6 +116,43 @@ module QA ...@@ -99,6 +116,43 @@ module QA
expect(index).not_to have_package(package_name) expect(index).not_to have_package(package_name)
end end
end end
it 'publishes and downloads a maven package via CI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1115' do
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
commit.commit_message = 'Add .gitlab-ci.yml'
commit.add_files([
{
file_path: '.gitlab-ci.yml',
content:
<<~YAML
deploy:
image: maven:3.6-jdk-11
script:
- 'mvn deploy -s settings.xml'
- "mvn dependency:get -Dartifact=#{group_id}:#{artifact_id}:1.0"
only:
- master
tags:
- "runner-for-#{project.name}"
YAML
},
settings_xml,
pom_xml
])
end
project.visit!
Flow::Pipeline.visit_latest_pipeline
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.click_job('deploy')
end
Page::Project::Job::Show.perform do |job|
expect(job).to be_successful(timeout: 800)
end
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment