Skip to content

Trigger pipeline and download artifacts from triggered pipeline #1021

@Letme

Description

@Letme

It should be a simple exercise, but in fact because of all the tokens it is not. There are few issues and I tried few variations, but to no avail. I am trying to trigger pipline and download artifacts of project A to pipeline that is running in project B and then use those artifacts to compile documentation.

Example I assembled based on documentation:

gl = gitlab.Gitlab('https://gitlab.melexis.com', job_token=os.environ['CI_JOB_TOKEN'])
project = gl.projects.get(project_id, lazy=True)
pipeline = project.trigger_pipeline('branchname', 'targetprojecttoken', variables={"VAR1": "True"})

# Start pipeline and wait for completion
while pipeline.finished_at is None:
    pipeline.refresh()
    time.sleep(1)

So, first problem was that I want to use CI_JOB_TOKEN to trigger the pipeline (not targetprojecttoken). This is something that can be done with curl, but here it does not work (tried with replacing targetprojecttoken with os.environ['CI_JOB_TOKEN'] but I get gitlab.exceptions.GitlabCreateError: 404: 404 Not Found).

Now for second more pressing issue here is that pipeline.refresh() returns gitlab.exceptions.GitlabGetError: 404: 404 Project Not Found although I confirmed that trigger_pipeline did trigger the pipeline.

Expected Behavior

Actual Behavior

  • trigger_pipeline works with targetprojecttoken instead of job_token
  • pipeline.refresh() returns gitlab.exceptions.GitlabGetError: 404: 404 Project Not Found

Specifications

  • python-gitlab version: 2.0.1
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): private

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions