Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git lab add trigger pipeline command #27544

Merged
merged 214 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 200 commits
Commits
Show all changes
214 commits
Select commit Hold shift + click to select a range
ded6610
add command
MosheEichler Jun 18, 2023
fa60a6b
fixes
MosheEichler Jun 18, 2023
0a53654
change client function name
MosheEichler Jun 18, 2023
2c2e84a
RN
MosheEichler Jun 19, 2023
7ee746d
Cloud Incident Response pack and Cloud Token Theft playbook (#27331)
melamedbn Jun 18, 2023
5af02dd
[ASM] - Expander - Update Service Ownership (#27140) (#27522)
content-bot Jun 18, 2023
e5499a8
[VMRay] fix encoding of file names (#27429) (#27527)
content-bot Jun 18, 2023
a210308
Xsoar file management (#26455)
maimorag Jun 18, 2023
01019cb
[VirusTotal] Fix only_stats default value (#27454)
content-bot Jun 18, 2023
aab5e0a
[Marketplace Contribution] Community Common Scripts - Content Pack Up…
content-bot Jun 18, 2023
4e6b036
[Jira v2] Added 3 new commands (#27523)
content-bot Jun 18, 2023
aeedc41
Updated description (#27524)
content-bot Jun 18, 2023
7cd2d79
Added new fields to context output and UI (#27069)
jlevypaloalto Jun 18, 2023
5820f25
Fix small grammar typos in documentation (#27489) (#27533)
content-bot Jun 18, 2023
1c969be
Support level tags for external contributions bug fix (#27167)
GuyAfik Jun 18, 2023
051c85f
Ivanti Pulse Secure Mapping (#27407)
eepstain Jun 18, 2023
54c3d0e
Aws iam enhancement (#27271)
YuvHayun Jun 18, 2023
728a210
Align credentials stores part 18 (#27441)
maimorag Jun 18, 2023
d1b716e
Cs falcon enhancement (#26136)
jlevypaloalto Jun 18, 2023
11556e2
pan-os-edit-rule command: Added support for removing and adding group…
rshunim Jun 18, 2023
391d3e9
[Marketplace Contribution] Generic Export Indicators Service - Conten…
content-bot Jun 19, 2023
9097c61
Update Docker Image To demisto/python3 (#27554)
content-bot Jun 19, 2023
959f618
Update Docker Image To demisto/py3-tools (#27553)
content-bot Jun 19, 2023
f9bfaff
Wildfire v2 - fix an issue in the wildfire-report command (#27547)
GuyAfik Jun 19, 2023
6f9526d
Azure Active Directory Identity: added test-module handling for clien…
moishce Jun 19, 2023
0d08153
Incident context core pb fix (#27546)
OmriItzhak Jun 19, 2023
ede878f
Fixed empty installation (#27541)
yucohen Jun 19, 2023
1867af8
Fixes for 'CrowdStrike Falcon - False Positive Incident Handling' pla…
TalNos Jun 19, 2023
bbc7ad4
Add retries to Trigger Test Upload Flow (#27537)
adi88d Jun 19, 2023
09edd70
Tenable sc enhancment (#26319)
YuvHayun Jun 19, 2023
bc0f904
Align Credentials Part 2 (#27350)
jlevypaloalto Jun 19, 2023
4417743
FreeEnrichers Pack - small fix to pack names that were wrong (#27445)
Ni-Knight Jun 19, 2023
1930999
add readme to Zscaler (#27465)
guytamir10 Jun 19, 2023
f0e5f90
Skyhigh SWG init (#27526)
content-bot Jun 19, 2023
990108e
[DBotPredictURLPhishing] - fix bug with None entires (#27563)
GuyAfik Jun 19, 2023
5831282
Align Credentials for GoogleCloudTranslate, Google Vision API, Google…
jlevypaloalto Jun 19, 2023
8573d5a
Versioned core packs (#25989)
darkushin Jun 19, 2023
b6aee7c
Ivanti Update (#27564)
eepstain Jun 19, 2023
a5e6f80
RTIR: fix add-comment (#27549)
dorschw Jun 19, 2023
d002b82
move pre-commit template to content (#27535)
ilaner Jun 19, 2023
d487593
Fix packs with demisto-sdk lint issues (#27392)
ilaner Jun 19, 2023
b37a09c
Added the missing defaultValue arg in the yml files (#27443)
ilappe Jun 19, 2023
69deea8
Fix For ADFS ModelingRules (#27568)
nkanon Jun 19, 2023
b2c2229
Update Docker Image To demisto/python3 (#27577)
content-bot Jun 20, 2023
9d5f131
GsuiteAdmin empty page token error (#27481)
anas-yousef Jun 20, 2023
d39f2d7
import-indicator-commands (#27558)
sapirshuker Jun 20, 2023
dec93b1
Update carbon black deprecated content (#27100)
OmriItzhak Jun 20, 2023
0d2fa5c
Remove unnecessary troubleshooting from README.md (#27531)
dansterenson Jun 20, 2023
7053fa9
Fix python 3 incompatibility for McAfee MAR (#27576)
amshamah419 Jun 20, 2023
db58f34
CVE command (#27580)
content-bot Jun 20, 2023
206b6f9
Remove redundant assignment of var (#27571)
thefrieddan1 Jun 20, 2023
93cfa1b
Feature/threatgrid add commands arguments (#27468) (#27590)
content-bot Jun 20, 2023
032561d
Partner otrs ag adoption start (#27256) (#27592)
content-bot Jun 20, 2023
c64ff28
Snow Transformer Error (#27479)
anas-yousef Jun 20, 2023
a60a26a
Domain extracted from a file with an extension as part of a URL (#27569)
Ni-Knight Jun 20, 2023
afaf226
Test playbook for 'CrowdStrike Falcon - Get Detections by Incident' (…
TalNos Jun 20, 2023
5cc6551
[TestIsMaliciousIndicatorFound] - add sleep for indexing indicators (…
GuyAfik Jun 20, 2023
7a99368
Microsoft usgov support (#27025)
kobymeir Jun 20, 2023
f325f78
Generic Webhook enhancements (#27478) (#27596)
content-bot Jun 21, 2023
9da2a23
Update Docker Image To demisto/pymisp2 (#27607)
content-bot Jun 21, 2023
759c4c5
Ciac 3134 workday logs (#27055)
eyalpalo Jun 21, 2023
026e28d
CrowdStrike Falcon - Search endpoints by hash enchantment (#27594)
ssokolovich Jun 21, 2023
f4ad51a
MacOS Update (#27608)
eepstain Jun 21, 2023
f9976e7
fix workday parsing rule id (#27615)
yucohen Jun 21, 2023
b58ed13
move a line in the yml to the correct position (#27610)
RosenbergYehuda Jun 21, 2023
f5dcdfd
Barracuda Update (#27545)
eepstain Jun 21, 2023
bebe153
Align credentials stores integrations- part 20 (#27534)
maimorag Jun 21, 2023
46d10f3
SMB - fix path concatenation (#27604)
darkushin Jun 21, 2023
d3affce
1.17.0 sdk release (#27618)
yucohen Jun 21, 2023
41747ce
Update ewsv2 exc2019 (#26670)
ostolero Jun 21, 2023
79fe635
added prettyName to host incident field (#27536)
dansterenson Jun 21, 2023
66c522b
Cloud Token Theft Enhancement (#27591)
melamedbn Jun 22, 2023
784514f
Update Docker Image To demisto/oci (#27631)
content-bot Jun 22, 2023
bec2a99
Update Docker Image To demisto/boto3py3 (#27629)
content-bot Jun 22, 2023
4090fc7
Update Docker Image To demisto/fastapi (#27635)
content-bot Jun 22, 2023
31a3ac6
Update Docker Image To demisto/bottle (#27638)
content-bot Jun 22, 2023
9699197
Update Docker Image To demisto/py3-tools (#27630)
content-bot Jun 22, 2023
ab1aa7d
Update Docker Image To demisto/crypto (#27632)
content-bot Jun 22, 2023
ef62077
Update Docker Image To demisto/py3ews (#27637)
content-bot Jun 22, 2023
0a599a4
Update Docker Image To demisto/pyjwt3 (#27634)
content-bot Jun 22, 2023
9f9a35f
Update Docker Image To demisto/python3 (#27628)
content-bot Jun 22, 2023
245d5ee
Update Docker Image To demisto/greynoise (#27636)
content-bot Jun 22, 2023
2005156
Update Docker Image To demisto/taxii2 (#27633)
content-bot Jun 22, 2023
b99e265
Update Docker Image To demisto/trustar (#27639)
content-bot Jun 22, 2023
cab47d2
Update Docker Image To demisto/glpi (#27647)
content-bot Jun 22, 2023
a996359
Update Docker Image To demisto/rubrik-polaris-sdk-py3 (#27642)
content-bot Jun 22, 2023
30d44b3
Update Docker Image To demisto/netmiko (#27648)
content-bot Jun 22, 2023
ae85c46
Update Docker Image To demisto/sixgill (#27645)
content-bot Jun 22, 2023
9bc7982
Update Docker Image To demisto/datadog-api-client (#27643)
content-bot Jun 22, 2023
e55015a
Update Docker Image To demisto/google-api-py3 (#27640)
content-bot Jun 22, 2023
43edd80
Update Docker Image To demisto/devo (#27641)
content-bot Jun 22, 2023
6edd044
remove xsoar marketplace (#27650)
guytamir10 Jun 22, 2023
45b740f
Phishing Campaign - perpetual lock fix and improvements (#27471)
idovandijk Jun 22, 2023
3aebd94
hide the pack (#27652)
merit-maita Jun 22, 2023
13994e8
Align Credentials Part 3 (#27371)
jlevypaloalto Jun 22, 2023
d3a1536
Align credentials stores part 19 (#27463)
maimorag Jun 22, 2023
21616fc
Align credentials stores part 12 (#27255)
maimorag Jun 22, 2023
43eb25f
Test playbook fixes (#27627)
GuyAfik Jun 22, 2023
41e60cf
Align credentials stores part 21 (#27565)
maimorag Jun 22, 2023
c03511d
Align credentials stores part 17 (#27433)
maimorag Jun 22, 2023
95a6e2c
Align credentials stores part 13 (#27289)
maimorag Jun 22, 2023
c27826d
Zendesk enhancement (#27101)
Shellyber Jun 22, 2023
8d1bf8f
Update demisto-sdk pre-commit version (#27658)
ilaner Jun 22, 2023
53eaeb4
Phishing Campaign - GetCampaignIncidentsInfo handling deleted inciden…
rshunim Jun 22, 2023
c182789
fix a bug in Cortex XDR - XQL Query Engine - replace 'tenant_ids' wit…
RosenbergYehuda Jun 22, 2023
4071cd4
salesforce Deprecation (#27548)
guytamir10 Jun 22, 2023
1d7d958
Phishing add subject to layout (#27669)
ArikDay Jun 22, 2023
d36d987
Update Docker Image To demisto/slackv3 (#27676)
content-bot Jun 23, 2023
6f5cd97
Update Docker Image To demisto/python3 (#27677)
content-bot Jun 23, 2023
030ce31
Threat connect outputs (#27257)
ShahafBenYakir Jun 23, 2023
71e4c0e
Update Docker Image To demisto/python3 (#27682)
content-bot Jun 25, 2023
636deda
Update Docker Image To demisto/python3 (#27689)
content-bot Jun 25, 2023
f9899a4
Update Docker Image To demisto/python3 (#27688)
content-bot Jun 25, 2023
4f28a77
Align Creds for PaloAltoNetworksIoT3rdParty, ImpervaSkyfence, FireEye…
jlevypaloalto Jun 25, 2023
2c3360f
Crowdstrike OpenAPI: Fixed the the cs-download-sensor-installer-by-id…
moishce Jun 25, 2023
0cd05c2
Align Credentials for GSuiteAdmin, SymantecMSS, AlienVault_USM_Anywhe…
jlevypaloalto Jun 25, 2023
e16bd7d
Cisco ASA Enhancement (#27620)
content-bot Jun 25, 2023
f160261
Align CVE argument (#27573)
yaakovpraisler Jun 25, 2023
07a399b
Align Credentials for BmcHelixRemedyForce, GoogleCloudFunctions, OPSW…
jlevypaloalto Jun 25, 2023
821d914
change env variables to gold ng (#27662)
adi88d Jun 25, 2023
45f4ccc
GitHub actions poetry (#27435)
merit-maita Jun 25, 2023
7bb0d68
Added Opensearch support for Elasticsearch feed (#27623)
content-bot Jun 25, 2023
5acef60
Align credentials stores - part 22 (#27683)
maimorag Jun 25, 2023
3e7cfc1
Align Credentials for Akamai SIEM, GSuite Security Alert Center, Thre…
jlevypaloalto Jun 25, 2023
63dd646
Bugfix/XSUP-23391/IBM-QRadar-v3-time-handling-API19 (#27567)
efelmandar Jun 25, 2023
e9cb0ca
Align credentials stores - part 24 (#27698)
maimorag Jun 25, 2023
3765546
Created a new playbook to perform YARA scan (#27703)
altmannyarden Jun 25, 2023
c7ffdf2
Update Docker Image To demisto/python3 (#27709)
content-bot Jun 26, 2023
5c49730
Update Docker Image To demisto/py3-tools (#27706)
content-bot Jun 26, 2023
d43983e
Update Docker Image To demisto/py3-tools (#27710)
content-bot Jun 26, 2023
d552ec7
added notes to ms teams readme (#27690)
merit-maita Jun 26, 2023
e6c2fd6
Skip core pack installation in XSIAM (#27692)
adi88d Jun 26, 2023
22b7ce5
Update Docker Image To demisto/python3 (#27707)
content-bot Jun 26, 2023
ef5a775
Attack Pattern layout typo fix (intrusion-set -> attack pattern) (#27…
Ni-Knight Jun 26, 2023
8fcc748
Add TIM Processing pack to XSIAM (#27653)
melamedbn Jun 26, 2023
fe38f21
Google align credentials stores - part 25 (#27699)
maimorag Jun 26, 2023
369d886
Microsoft Align credentials stores -part 23 (#27684)
maimorag Jun 26, 2023
f5609c6
Fix test upload flow - alibaba modeling rule ID change (#27656)
yucohen Jun 26, 2023
0375677
added mp to tim processing layouts (#27724)
yucohen Jun 26, 2023
60fe988
fix Test - CrowdStrike Falcon TPB (#27719)
GuyAfik Jun 26, 2023
0b69176
Azure security center modeling rule incorrect syntax (#27691)
rshunim Jun 26, 2023
a9b2b29
[Elasticsearch Feed] Authentication Error Bug FIx (#27614)
samuelFain Jun 26, 2023
03b66ae
Remove two deprecated packs from Common Widgets (#27694)
rshunim Jun 26, 2023
39a72f9
Documentation (#27730)
rshunim Jun 26, 2023
ce91c16
Align credentials stores part 28 (#27727)
maimorag Jun 26, 2023
bbf371f
Add documentation to 2 wrapper packs: free feed & free enrichers (#27…
RosenbergYehuda Jun 26, 2023
c6f326b
update ruff rules (#27732)
dorschw Jun 26, 2023
6567d81
Changed the 'key' input value of the 'Get full detection details' tas…
TalNos Jun 26, 2023
b43ae93
[marketplace contributions] - fix issue with support labels (#27600)
GuyAfik Jun 26, 2023
96ed2b8
update Docker (#27737)
moishce Jun 26, 2023
672f42b
Jira V3 - Added missing assert to unit tests (#27738)
anas-yousef Jun 26, 2023
c5aa066
Fix GmailSingleUser bug (#27704)
israelpoli Jun 26, 2023
32553b6
Update Docker Image To demisto/taxii-server (#27746)
content-bot Jun 27, 2023
e1760a8
Update Docker Image To demisto/python3 (#27745)
content-bot Jun 27, 2023
9c5388f
Update Docker Image To demisto/splunksdk-py3 (#27743)
content-bot Jun 27, 2023
020f749
Cloud Token Theft Enhancement v2 (#27716)
melamedbn Jun 27, 2023
1940b63
Update IncidentType-Zerohack_XDR.json (#27611)
edik24 Jun 27, 2023
788ee2a
Align Credentials for BPA, Cisco-umbrella-investigate (#27735)
jlevypaloalto Jun 27, 2023
1dbec69
Add new command and evolve scan command (#27725)
content-bot Jun 27, 2023
7472a77
Remove playbook0 from RecordedFutureAlert.json (#27539)
edik24 Jun 27, 2023
ab82488
remove workflow that use with CG on-prem (#27687)
israelpoli Jun 27, 2023
d9786b9
[Marketplace Contribution] Oracle Cloud Infrastructure Feed (#27670) …
content-bot Jun 27, 2023
2dd3af2
[SplunkPy] code improvement (#27750)
shmuel44 Jun 27, 2023
bfdbaa2
[Marketplace Contribution] ExtraHop Reveal(x) - Content Pack Update (…
content-bot Jun 27, 2023
9e62e5b
Align credentials stores - part 27 (#27721)
maimorag Jun 27, 2023
83fc7ac
MS Security Graph Update2 (#27695)
eepstain Jun 27, 2023
418f854
Align credentials stores - part 31 (#27736)
maimorag Jun 27, 2023
687ad0c
Edit Jira V2 and V3 description (#27762)
anas-yousef Jun 27, 2023
5e6d1b2
Fix feed misp bug (#27748)
israelpoli Jun 27, 2023
0ce3977
Packs/Reco: fix validate_api_key (#27731) (#27767)
content-bot Jun 27, 2023
c8b9078
WildFire update for MAEC report output (#27766)
content-bot Jun 27, 2023
b310d8c
Update Docker Image To demisto/py3-tools (#27778)
content-bot Jun 28, 2023
9f02c7d
Update Docker Image To demisto/python3 (#27779)
content-bot Jun 28, 2023
62d7359
Supported to take single value as an array having the value. (#27646)…
content-bot Jun 28, 2023
e96a65d
added CortexAttackSurfaceManagement to unremovable packs (#27749)
yucohen Jun 28, 2023
340a923
Align Credentials for GooglePubSub, DHS_Feed, Rapid7_InsightIDR (#27697)
jlevypaloalto Jun 28, 2023
9646d79
Disable `urllib3` warnings in CSP (#27773)
dorschw Jun 28, 2023
2e9e2d0
Prisma sase playbooks (#26162)
ssokolovich Jun 28, 2023
e20ae79
[ASM] - Expander - Remediation Confirmation Scan (#27605) (#27780)
content-bot Jun 28, 2023
3308b1e
MISP feed - Update Query documentation (#27713)
amshamah419 Jun 28, 2023
421fd37
[PAN-OS] Add Ipv4/IPv6 sinkhole arguments (#27622)
samuelFain Jun 28, 2023
ab9fe95
Removing 2 widgets from the library (#27747)
rshunim Jun 28, 2023
7e513a0
Taking ownership of TIM code and some TIM main integrations (#27782)
Ni-Knight Jun 28, 2023
f1203d7
Yr--azure key vault--support multiple subscription ids & resource gro…
RosenbergYehuda Jun 28, 2023
703a0fb
Removed Default Playbook from TrendMicro Vision One XDR Incident (#27…
kgal-pan Jun 28, 2023
384eab3
Dlp enhancements (#27612)
tomer-pan Jun 28, 2023
a146560
Add Reputation "Reliability" Parameter (#27438)
DinaMeylakh Jun 28, 2023
5005b2e
fix None type header in archer v2 (#27382)
esharf Jun 28, 2023
bed032c
Fix is incident part of campaign bug (#27787)
israelpoli Jun 28, 2023
492bb9d
FireEyeHX Create Indicator Enhacement (#27717)
content-bot Jun 28, 2023
ae1b877
trigger variable
MosheEichler Jul 2, 2023
653dafb
Merge branch 'master' into GitLab_add_trigger_nightly_command
MosheEichler Jul 2, 2023
e5f1721
conflicts
MosheEichler Jul 2, 2023
8956094
revert
MosheEichler Jul 2, 2023
e62029b
version
MosheEichler Jul 2, 2023
81f894b
readme
MosheEichler Jul 3, 2023
5811533
UT
MosheEichler Jul 3, 2023
de430be
Merge branch 'master' into GitLab_add_trigger_nightly_command
MosheEichler Jul 3, 2023
0baf7ca
CR fixes
MosheEichler Jul 3, 2023
1b7c318
Merge branch 'master' into GitLab_add_trigger_nightly_command
MosheEichler Jul 3, 2023
cca6668
more CR fixes
MosheEichler Jul 4, 2023
ecccb5c
Merge branch 'master' into GitLab_add_trigger_nightly_command
MosheEichler Jul 4, 2023
a385519
lint fixes
MosheEichler Jul 4, 2023
86542bf
Merge branch 'master' into GitLab_add_trigger_nightly_command
MosheEichler Jul 4, 2023
fc3c979
pre-commit fixes
MosheEichler Jul 4, 2023
1fbac5a
Merge branch 'master' into GitLab_add_trigger_nightly_command
MosheEichler Jul 6, 2023
ef6e776
conflicts
MosheEichler Jul 6, 2023
25dcb32
Merge branch 'master' into GitLab_add_trigger_nightly_command
MosheEichler Jul 9, 2023
c1fd085
Fix TPB
MosheEichler Jul 10, 2023
db145c0
Merge branch 'master' into GitLab_add_trigger_nightly_command
MosheEichler Jul 10, 2023
e06f86d
רקהקרא בישמעקד
MosheEichler Jul 11, 2023
c9c7469
Merge branch 'master' into GitLab_add_trigger_nightly_command
MosheEichler Jul 11, 2023
8ff468d
is_mockable
MosheEichler Jul 11, 2023
10a7fb1
Merge branch 'master' into GitLab_add_trigger_nightly_command
MosheEichler Jul 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 54 additions & 2 deletions Packs/GitLab/Integrations/GitLabv2/GitLabv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@


class Client(BaseClient):
def __init__(self, project_id, base_url, verify, proxy, headers):
def __init__(self, project_id, base_url, verify, proxy, headers, trigger_token=None):
super().__init__(base_url=base_url, verify=verify, proxy=proxy, headers=headers)
self.project_id = project_id
self.trigger_token = trigger_token

def group_projects_list_request(self, params: dict | None, group_id: str | None) -> dict:
headers = self._headers
Expand Down Expand Up @@ -314,6 +315,19 @@ def get_job_artifact_request(self, project_id: str, job_id: str, artifact_path_s
suffix = f'projects/{project_id}/jobs/{job_id}/artifacts/{artifact_path_suffix}'
return self._http_request('get', suffix, headers=headers, resp_type='text')

def gitlab_trigger_pipeline(self, project_id: str, data: dict) -> dict:
"""Triggers a pipeline on GitLab.

Args:
project_id: Project ID on winch to run the pipeline.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
project_id: Project ID on winch to run the pipeline.
project_id: Project ID on which to run the pipeline.

data: The request body in JSON format.

Returns:
dict: The response in JSON format.
"""
suffix = f'projects/{project_id}/trigger/pipeline'
return self._http_request('POST', suffix, data=data)


''' HELPER FUNCTIONS '''

Expand Down Expand Up @@ -1698,6 +1712,42 @@ def gitlab_artifact_get_command(client: Client, args: Dict[str, Any]) -> Command
)


def gitlab_trigger_pipeline_command(client: Client, args: dict[str, str]) -> CommandResults:
"""
Triggers a GitLab pipeline on a selected project and branch.
Args:
client (Client): Client to perform calls to GitLab services.
args (dict) XSOAR arguments:
- 'project_id': Project ID on which to run the pipeline.
- 'ref_branch': The branch on which to run the pipeline. Default is 'master'

Returns:
(CommandResults).
"""
project_id = args.get('project_id') or client.project_id
bziser marked this conversation as resolved.
Show resolved Hide resolved
if not client.trigger_token:
return_error("A trigger token is required in the integration instance configuration")
data = {
'token': client.trigger_token,
'ref': args.get('ref_branch', 'master'),
}
for key, value in json.loads(args.get('trigger_variables', '{}')).items():
data[f'variables[{key}]'] = value

response = client.gitlab_trigger_pipeline(project_id, data)

outputs = {k: v for k, v in response.items() if k in PIPELINE_FIELDS_TO_EXTRACT}
human_readable = tableToMarkdown('GitLab Pipeline', outputs, removeNull=True)

return CommandResults(
outputs_prefix='GitLab.Pipeline',
outputs_key_field='id',
outputs=outputs,
raw_response=response,
readable_output=human_readable
)


def check_for_html_in_error(e: str):
"""
Args:
Expand All @@ -1723,6 +1773,7 @@ def main() -> None: # pragma: no cover
LOG(f'Command being called is {command}')
server_url = params.get('url', '')
project_id = arg_to_number(params.get('project_id'), required=True)
trigger_token = params.get('trigger_token', {}).get('password')
commands = {'gitlab-group-project-list': group_project_list_command,
'gitlab-issue-create': create_issue_command,
'gitlab-branch-create': branch_create_command,
Expand Down Expand Up @@ -1758,10 +1809,11 @@ def main() -> None: # pragma: no cover
'gitlab-pipelines-schedules-list': gitlab_pipelines_schedules_list_command,
'gitlab-jobs-list': gitlab_jobs_list_command,
'gitlab-artifact-get': gitlab_artifact_get_command,
'gitlab-trigger-pipeline': gitlab_trigger_pipeline_command,
}

try:
client = Client(project_id, urljoin(server_url, ""), verify_certificate, proxy, headers=headers)
client = Client(project_id, urljoin(server_url, ""), verify_certificate, proxy, headers, trigger_token)
if project_id and verify_project_id(client, project_id):
if demisto.command() == 'test-module':
return_results(test_module(client))
Expand Down
84 changes: 82 additions & 2 deletions Packs/GitLab/Integrations/GitLabv2/GitLabv2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ configuration:
hiddenusername: true
required: true
type: 9
- displaypassword: Trigger Token
additionalinfo: The trigger token to run pipelines. For more info see https://docs.gitlab.com/ee/ci/triggers
name: trigger_token
hiddenusername: true
required: false
type: 9
- display: Project ID
additionalinfo: The project ID, it can be found under the project name.
name: project_id
Expand Down Expand Up @@ -3569,7 +3575,7 @@ script:
type: String
- contextPath: GitLab.PipelineSchedule.last_pipeline.status
description: Status of the last pipeline that was run by the scheduled pipeline. Relevant only when the pipeline schedule ID is given.
type: String
type: String
- name: gitlab-jobs-list
arguments:
- default: false
Expand Down Expand Up @@ -3651,7 +3657,7 @@ script:
isArray: false
name: artifact_path_suffix
required: true
secret: false
secret: false
description: Gets an artifact from a given artifact path, corresponding to a given job ID.
execution: false
outputs:
Expand All @@ -3664,6 +3670,80 @@ script:
- contextPath: GitLab.Artifact.artifact_data
description: Data of the artifact requested.
type: String
- name: gitlab-trigger-pipeline
arguments:
- default: false
description: Project ID on which to run the pipeline.
isArray: false
name: project_id
required: false
secret: false
- default: false
description: The branch on which to run the pipeline. Default is 'master'.
isArray: false
name: ref_branch
required: false
secret: false
- default: false
description: JSON containing the pipeline variables.
isArray: false
name: trigger_variables
required: false
secret: false
description: Triggers a GitLab pipeline on a selected project and branch.
execution: false
outputs:
- contextPath: GitLab.Pipeline.id
description: Pipeline ID.
type: Number
- contextPath: GitLab.Pipeline.project_id
description: Project ID that the pipeline belongs to.
type: Number
- contextPath: GitLab.Pipeline.status
description: Status of the pipeline.
type: String
- contextPath: GitLab.Pipeline.ref
description: Reference of the pipeline.
type: String
- contextPath: GitLab.Pipeline.sha
description: SHA of the pipeline.
type: String
- contextPath: GitLab.Pipeline.created_at
description: Time when the pipeline was created.
type: Date
- contextPath: GitLab.Pipeline.updated_at
description: Time when the pipeline was last updated.
type: Date
- contextPath: GitLab.Pipeline.started_at
description: Time when the pipeline was started.
type: Date
- contextPath: GitLab.Pipeline.finished_at
description: Time when the pipeline was finished.
type: Date
- contextPath: GitLab.Pipeline.duration
description: Duration of the pipeline in seconds.
type: Number
- contextPath: GitLab.Pipeline.web_url
description: Web URL of the pipeline.
type: String
- contextPath: GitLab.Pipeline.user.name
description: Name of the user who triggered the pipeline.
type: String
- contextPath: GitLab.Pipeline.user.username
description: Username that triggered the pipeline.
type: String
- contextPath: GitLab.Pipeline.user.id
description: ID of the user who triggered the pipeline.
type: Number
- contextPath: GitLab.Pipeline.user.state
description: State of the user who triggered the pipeline.
type: String
- contextPath: GitLab.Pipeline.user.avatar_url
description: Avatar URL of the user who triggered the pipeline.
type: String
- contextPath: GitLab.Pipeline.user.web_url
description: Web URL of the user who triggered the pipeline.
type: String
isfetch: false
runonce: false
script: '-'
Expand Down
42 changes: 42 additions & 0 deletions Packs/GitLab/Integrations/GitLabv2/GitLabv2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,3 +986,45 @@ def test_return_date_arg_as_iso(arg, isValidDate, expected_response):
return_date_arg_as_iso(arg)

assert str(e.value) == expected_response


@pytest.mark.parametrize('trigger_token, args, expected_result', [
('', {}, util_load_json('test_data/commands_test_data.json').get('trigger_pipeline1')),
(1111, {'project_id': 2222, 'ref_branch': 'test'}, util_load_json('test_data/commands_test_data.json').get('trigger_pipeline2'))
])
def test_trigger_pipeline(mocker, trigger_token, args, expected_result):
bziser marked this conversation as resolved.
Show resolved Hide resolved
"""
Given:
- client and demisto args
- case 1 - client without trigger token.
- case 2 - client with trigger token and args with a different project ID than the instance.
When:
- gitlab_trigger_pipeline_command
Then:
- The response is as expected
- case 1 - Throws an error about the trigger token that is missing
- case 2 - The response is correct with the same branch and project_id as in the args.
"""
from GitLabv2 import Client, gitlab_trigger_pipeline_command
client = Client(project_id=1234,
base_url="base_url",
verify=False,
proxy=False,
headers={'PRIVATE-TOKEN': 'api_key'},
trigger_token=trigger_token)
expected_outputs: List[Dict] = expected_result['expected_outputs']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expected_outputs: List[Dict] = expected_result['expected_outputs']
expected_outputs: list[dict] = expected_result['expected_outputs']

expected_prefix: str = expected_result['expected_prefix']
expected_key_field: str = expected_result['expected_key_field']
mocker.patch.object(Client, '_http_request', return_value=expected_result['mock_response'])
mock_error = mocker.patch('GitLabv2.return_error')

command_result = gitlab_trigger_pipeline_command(client, args)

if not trigger_token:
assert mock_error.call_args[0][0] == 'A trigger token is required in the integration instance configuration'
else:
assert command_result.outputs_prefix == expected_prefix
assert command_result.outputs_key_field == expected_key_field
assert command_result.outputs == expected_outputs
assert command_result.outputs.get('ref') == args.get('ref_branch')
assert command_result.outputs.get('project_id') == args.get('project_id')
53 changes: 53 additions & 0 deletions Packs/GitLab/Integrations/GitLabv2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This integration enables you to:
- Get a list of files in the GitLab project.
- Get the contents and details of a file in GitLab.
- Search for code in the GitLab project.
- Trigger a pipeline in the GitLab project.

#### Create a Personal Access Token
Personal access tokens (PATs) are an alternative to using passwords for authentication to GitLab when using the GitLab API.
Expand All @@ -28,6 +29,18 @@ To generate a new token:
6. Select the **scopes**, or **permissions**, you want to grant this token. The minimum is read-only on repo.
7. Click **Create personal access token** and copy the api key generated.-+

#### Create a Trigger Token
Trigger tokens allows you to trigger a pipeline for a branch using it to authenticate on an API call.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Trigger tokens allows you to trigger a pipeline for a branch using it to authenticate on an API call.
Trigger tokens allow you to trigger a pipeline for a branch using it to authenticate on an API call.

Prerequisite:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Prerequisite:
**Prerequisite:**

- You must have at least the Maintainer role for the project.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- You must have at least the Maintainer role for the project.
You must have at least the Maintainer role for the project.

To generate a new token:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To generate a new token:
**To generate a new token:**

1. Navigate to your project.
2. Select Settings > CI/CD.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. Select Settings > CI/CD.
2. Select **Settings** > **CI/CD**.

3. Expand Pipeline triggers.
4. Enter a description and select Add trigger.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
4. Enter a description and select Add trigger.
4. Enter a description and select **Add trigger**.

- You can view and copy the full token for all triggers you have created.
- You can only see the first 4 characters for tokens created by other project members.

#### Get Project ID
1. Go to the desired project example gitlab.com/username/project1.
2. Under the project name get the argument project_id
Expand All @@ -42,6 +55,7 @@ To generate a new token:
| --- | --- | --- |
| Server URL (e.g. https://gitlab.com/api/v4) | | False |
| API Key | The API Key to use for connection | True |
| Trigger Token | The trigger token to run pipelines | False |
| Project ID | | True |
| Trust any certificate (not secure) | | False |
| Use system proxy settings | | False |
Expand Down Expand Up @@ -2144,3 +2158,42 @@ Gets an artifact from a given artifact path, corresponding to a given job ID.
| GitLab.Artifact.job_id | String | Job ID from which the artifact was taken. |
| GitLab.Artifact.artifact_path_suffix | String | Suffix of the given artifact path. |
| GitLab.Artifact.artifact_data | String | Data of the artifact requested. |

### gitlab-trigger-pipeline

***
Triggers a GitLab pipeline on a selected project and branch.

#### Base Command

`gitlab-trigger-pipeline`

#### Input

| **Argument Name** | **Description** | **Required** |
| --- | --- | --- |
| project_id | Project ID on which to run the pipeline. | Optional |
| ref_branch | The branch on which to run the pipeline. Default is 'master'. | Optional |
| trigger_variables | JSON containing the pipeline variables. | Optional |

#### Context Output

| **Path** | **Type** | **Description** |
| --- | --- | --- |
| GitLab.Pipeline.id | Number | Pipeline ID. |
| GitLab.Pipeline.project_id | Number | Project ID that the pipeline belongs to. |
| GitLab.Pipeline.status | String | Status of the pipeline. |
| GitLab.Pipeline.ref | String | Reference of the pipeline. |
| GitLab.Pipeline.sha | String | SHA of the pipeline. |
| GitLab.Pipeline.created_at | Date | Time when the pipeline was created. |
| GitLab.Pipeline.updated_at | Date | Time when the pipeline was last updated. |
| GitLab.Pipeline.started_at | Date | Time when the pipeline was started. |
| GitLab.Pipeline.finished_at | Date | Time when the pipeline was finished. |
| GitLab.Pipeline.duration | Number | Duration of the pipeline in seconds. |
| GitLab.Pipeline.web_url | String | Web URL of the pipeline. |
| GitLab.Pipeline.user.name | String | Name of the user who triggered the pipeline. |
| GitLab.Pipeline.user.username | String | Username that triggered the pipeline. |
| GitLab.Pipeline.user.id | Number | ID of the user who triggered the pipeline. |
| GitLab.Pipeline.user.state | String | State of the user who triggered the pipeline. |
| GitLab.Pipeline.user.avatar_url | String | Avatar URL of the user who trigerred the pipeline. |
| GitLab.Pipeline.user.web_url | String | Web URL of the user who triggered the pipeline. |
Original file line number Diff line number Diff line change
Expand Up @@ -1193,5 +1193,55 @@
"expected_prefix": "GitLab.PipelineSchedule",
"expected_url_mock_suffix": "projects/1/pipeline_schedules",
"expected_key_field": "id"
},
"trigger_pipeline1": {
"mock_response": {
"id": 1,
"project_id": 1234,
"sha": "skd5h31245ljkasl4kj45l324",
"ref": "master",
"status": "running",
"created_at": "2021-06-15T14:31:29.607Z",
"updated_at": "2021-06-15T14:31:32.964Z",
"web_url": "https://server_url/project/-/pipelines/1"
},
"expected_outputs": {
"id": 1,
"project_id": 1234,
"sha": "skd5h31245ljkasl4kj45l324",
"ref": "master",
"status": "running",
"created_at": "2021-06-15T14:31:29.607Z",
"updated_at": "2021-06-15T14:31:32.964Z",
"web_url": "https://server_url/project/-/pipelines/1"
},
"expected_prefix": "GitLab.Pipeline",
"expected_url_mock_suffix": "projects/1234/pipelines",
"expected_key_field": "id"
},
"trigger_pipeline2": {
"mock_response": {
"id": 1,
"project_id": 2222,
"sha": "skd5h31245ljkasl4kj45l324",
"ref": "test",
"status": "running",
"created_at": "2021-06-15T14:31:29.607Z",
"updated_at": "2021-06-15T14:31:32.964Z",
"web_url": "https://server_url/project/-/pipelines/1"
},
"expected_outputs": {
"id": 1,
"project_id": 2222,
"sha": "skd5h31245ljkasl4kj45l324",
"ref": "test",
"status": "running",
"created_at": "2021-06-15T14:31:29.607Z",
"updated_at": "2021-06-15T14:31:32.964Z",
"web_url": "https://server_url/project/-/pipelines/1"
},
"expected_prefix": "GitLab.Pipeline",
"expected_url_mock_suffix": "projects/2222/pipelines",
"expected_key_field": "id"
}
}
4 changes: 4 additions & 0 deletions Packs/GitLab/ReleaseNotes/2_2_11.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

#### Integrations
##### GitLab v2
Added the new ***gitlab-trigger-pipeline*** command to trigger a GitLab pipeline.
Loading