Yaml code fails while running msg: "{{ job_info[0][\"JOB_NAME\"] }}" - ansible

Here is my Yaml code.
---
- hosts: as053a
gather_facts: false
collections:
- ibm.power_ibmi
vars:
job_info: ""
tasks:
- name: Submit a batch job and run CALL QGPL/PGM1
ibm.power_ibmi.ibmi_submit_job:
cmd: DSPPTF OUTPUT(*PRINT)
- name: Get status of a list of jobs
ibm.power_ibmi.ibmi_job:
user: MSRXS
type: "*BATCH"
register: job_info
- name: Debug job info
debug:
var: job_info
- name: Print the job name or names
debug:
msg: "{{ job_info[0][\"JOB_NAME\"] }}"
Basically I'm trying to run a command & get the process ID & other details from a IBMi system.
Out of the four tasks, 3 tasks run successfully, but the fourth task fails with below error message:
fatal: [as053a]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: dict object has no element 0\n\nThe error appears to be in '/tmp/bwrap_7266694_r5nf2p16/awx_7266694_2sgugv1b/project/as053a.dspptf.yaml': line 20, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n var: job_info\n - name: Print the job name or names\n ^ here\n"}
Please let me what needs to be done
The output of third task looks like below:
"job_info": {
"end": "2023-02-18 05:03:14.796003",
"job_log": [],
"failed": false,
"changed": false,
"job_info": [
{
"JOB_STATUS": "OUTQ",
"JOB_QUEUE_NAME": "IBMSAJOBQ",
"JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
"JOB_TYPE": "BCH",
"JOB_ACCOUNTING_CODE": "IBM 123385 897",
"CCSID": 37,
"JOB_END_TIME": "2023-02-17 23:02:23",
"SUBMITTER_JOB_NAME": "927415/MSRXS/QPADEV000C",
"JOB_ENTERED_SYSTEM_TIME": "2023-02-17 23:02:23",
"JOB_DESCRIPTION": "ISYSJOBD",
"JOB_INFORMATION": "YES",
"JOB_NAME": "927529/MSRXS/ISYSJOBD",
"JOB_TYPE_ENHANCED": "BATCH",
"COMPLETION_STATUS": "ABNORMAL",
"JOB_DATE": "",
"JOB_ACTIVE_TIME": "2023-02-17 23:02:23",
"JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
"JOB_QUEUE_STATUS": "RELEASED",
"SUBMITTER_MESSAGE_QUEUE": "MSRXS",
"JOB_SUBSYSTEM": "",
"SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
"JOB_SCHEDULED_TIME": "",
"JOB_END_REASON": "JOB ENDED DUE TO THE MESSAGE SEVERITY LEVEL BEING EXCEEDED",
"JOB_QUEUE_PRIORITY": "",
"JOB_END_SEVERITY": 30
},
{
"JOB_STATUS": "OUTQ",
"JOB_QUEUE_NAME": "",
"JOB_DESCRIPTION_LIBRARY": "",
"JOB_TYPE": "BCH",
"JOB_ACCOUNTING_CODE": "IBM 123385 897",
"CCSID": "",
"JOB_END_TIME": "2023-02-17 23:55:28",
"SUBMITTER_JOB_NAME": "",
"JOB_ENTERED_SYSTEM_TIME": "2023-02-17 23:55:28",
"JOB_DESCRIPTION": "",
"JOB_INFORMATION": "YES",
"JOB_NAME": "928197/MSRXS/QPRTJOB",
"JOB_TYPE_ENHANCED": "ALTERNATE_SPOOL_USER",
"COMPLETION_STATUS": "ABNORMAL",
"JOB_DATE": "",
"JOB_ACTIVE_TIME": "",
"JOB_QUEUE_LIBRARY": "",
"JOB_QUEUE_STATUS": "",
"SUBMITTER_MESSAGE_QUEUE": "",
"JOB_SUBSYSTEM": "",
"SUBMITTER_MESSAGE_QUEUE_LIBRARY": "",
"JOB_SCHEDULED_TIME": "",
"JOB_END_REASON": "",
"JOB_QUEUE_PRIORITY": "",
"JOB_END_SEVERITY": 10
},
{
"JOB_STATUS": "OUTQ",
"JOB_QUEUE_NAME": "IBMSAJOBQ",
"JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
"JOB_TYPE": "BCH",
"JOB_ACCOUNTING_CODE": "IBM 123385 897",
"CCSID": 37,
"JOB_END_TIME": "2023-02-18 00:40:00",
"SUBMITTER_JOB_NAME": "928201/QUSER/QSQSRVR",
"JOB_ENTERED_SYSTEM_TIME": "2023-02-18 00:39:59",
"JOB_DESCRIPTION": "ISYSJOBD",
"JOB_INFORMATION": "YES",
"JOB_NAME": "928748/MSRXS/ISYSJOBD",
"JOB_TYPE_ENHANCED": "BATCH",
"COMPLETION_STATUS": "NORMAL",
"JOB_DATE": "",
"JOB_ACTIVE_TIME": "2023-02-18 00:40:00",
"JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
"JOB_QUEUE_STATUS": "RELEASED",
"SUBMITTER_MESSAGE_QUEUE": "MSRXS",
"JOB_SUBSYSTEM": "",
"SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
"JOB_SCHEDULED_TIME": "",
"JOB_END_REASON": "JOB ENDING IN NORMAL MANNER",
"JOB_QUEUE_PRIORITY": "",
"JOB_END_SEVERITY": 30
},
{
"JOB_STATUS": "OUTQ",
"JOB_QUEUE_NAME": "IBMSAJOBQ",
"JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
"JOB_TYPE": "BCH",
"JOB_ACCOUNTING_CODE": "IBM 123385 897",
"CCSID": 37,
"JOB_END_TIME": "2023-02-18 04:05:01",
"SUBMITTER_JOB_NAME": "915387/QUSER/QSQSRVR",
"JOB_ENTERED_SYSTEM_TIME": "2023-02-18 04:05:00",
"JOB_DESCRIPTION": "ISYSJOBD",
"JOB_INFORMATION": "YES",
"JOB_NAME": "931583/MSRXS/ISYSJOBD",
"JOB_TYPE_ENHANCED": "BATCH",
"COMPLETION_STATUS": "NORMAL",
"JOB_DATE": "",
"JOB_ACTIVE_TIME": "2023-02-18 04:05:00",
"JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
"JOB_QUEUE_STATUS": "RELEASED",
"SUBMITTER_MESSAGE_QUEUE": "MSRXS",
"JOB_SUBSYSTEM": "",
"SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
"JOB_SCHEDULED_TIME": "",
"JOB_END_REASON": "JOB ENDING IN NORMAL MANNER",
"JOB_QUEUE_PRIORITY": "",
"JOB_END_SEVERITY": 30
},
{
"JOB_STATUS": "OUTQ",
"JOB_QUEUE_NAME": "IBMSAJOBQ",
"JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
"JOB_TYPE": "BCH",
"JOB_ACCOUNTING_CODE": "IBM 123385 897",
"CCSID": 37,
"JOB_END_TIME": "2023-02-18 04:29:54",
"SUBMITTER_JOB_NAME": "915387/QUSER/QSQSRVR",
"JOB_ENTERED_SYSTEM_TIME": "2023-02-18 04:29:53",
"JOB_DESCRIPTION": "ISYSJOBD",
"JOB_INFORMATION": "YES",
"JOB_NAME": "932009/MSRXS/ISYSJOBD",
"JOB_TYPE_ENHANCED": "BATCH",
"COMPLETION_STATUS": "NORMAL",
"JOB_DATE": "",
"JOB_ACTIVE_TIME": "2023-02-18 04:29:53",
"JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
"JOB_QUEUE_STATUS": "RELEASED",
"SUBMITTER_MESSAGE_QUEUE": "MSRXS",
"JOB_SUBSYSTEM": "",
"SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
"JOB_SCHEDULED_TIME": "",
"JOB_END_REASON": "JOB ENDING IN NORMAL MANNER",
"JOB_QUEUE_PRIORITY": "",
"JOB_END_SEVERITY": 30
},
{
"JOB_STATUS": "OUTQ",
"JOB_QUEUE_NAME": "IBMSAJOBQ",
"JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
"JOB_TYPE": "BCH",
"JOB_ACCOUNTING_CODE": "IBM 123385 897",
"CCSID": 37,
"JOB_END_TIME": "2023-02-18 04:36:25",
"SUBMITTER_JOB_NAME": "915387/QUSER/QSQSRVR",
"JOB_ENTERED_SYSTEM_TIME": "2023-02-18 04:36:24",
"JOB_DESCRIPTION": "ISYSJOBD",
"JOB_INFORMATION": "YES",
"JOB_NAME": "932122/MSRXS/ISYSJOBD",
"JOB_TYPE_ENHANCED": "BATCH",
"COMPLETION_STATUS": "NORMAL",
"JOB_DATE": "",
"JOB_ACTIVE_TIME": "2023-02-18 04:36:24",
"JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
"JOB_QUEUE_STATUS": "RELEASED",
"SUBMITTER_MESSAGE_QUEUE": "MSRXS",
"JOB_SUBSYSTEM": "",
"SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
"JOB_SCHEDULED_TIME": "",
"JOB_END_REASON": "JOB ENDING IN NORMAL MANNER",
"JOB_QUEUE_PRIORITY": "",
"JOB_END_SEVERITY": 30
},
{
"JOB_STATUS": "OUTQ",
"JOB_QUEUE_NAME": "IBMSAJOBQ",
"JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
"JOB_TYPE": "BCH",
"JOB_ACCOUNTING_CODE": "IBM 123385 897",
"CCSID": 37,
"JOB_END_TIME": "2023-02-18 04:41:44",
"SUBMITTER_JOB_NAME": "915387/QUSER/QSQSRVR",
"JOB_ENTERED_SYSTEM_TIME": "2023-02-18 04:41:44",
"JOB_DESCRIPTION": "ISYSJOBD",
"JOB_INFORMATION": "YES",
"JOB_NAME": "932232/MSRXS/ISYSJOBD",
"JOB_TYPE_ENHANCED": "BATCH",
"COMPLETION_STATUS": "NORMAL",
"JOB_DATE": "",
"JOB_ACTIVE_TIME": "2023-02-18 04:41:44",
"JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
"JOB_QUEUE_STATUS": "RELEASED",
"SUBMITTER_MESSAGE_QUEUE": "MSRXS",
"JOB_SUBSYSTEM": "",
"SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
"JOB_SCHEDULED_TIME": "",
"JOB_END_REASON": "JOB ENDING IN NORMAL MANNER",
"JOB_QUEUE_PRIORITY": "",
"JOB_END_SEVERITY": 30
},
{
"JOB_STATUS": "OUTQ",
"JOB_QUEUE_NAME": "IBMSAJOBQ",
"JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
"JOB_TYPE": "BCH",
"JOB_ACCOUNTING_CODE": "IBM 123385 897",
"CCSID": 37,
"JOB_END_TIME": "2023-02-18 04:59:55",
"SUBMITTER_JOB_NAME": "915387/QUSER/QSQSRVR",
"JOB_ENTERED_SYSTEM_TIME": "2023-02-18 04:59:55",
"JOB_DESCRIPTION": "ISYSJOBD",
"JOB_INFORMATION": "YES",
"JOB_NAME": "932541/MSRXS/ISYSJOBD",
"JOB_TYPE_ENHANCED": "BATCH",
"COMPLETION_STATUS": "NORMAL",
"JOB_DATE": "",
"JOB_ACTIVE_TIME": "2023-02-18 04:59:55",
"JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
"JOB_QUEUE_STATUS": "RELEASED",
"SUBMITTER_MESSAGE_QUEUE": "MSRXS",
"JOB_SUBSYSTEM": "",
"SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
"JOB_SCHEDULED_TIME": "",
"JOB_END_REASON": "JOB ENDING IN NORMAL MANNER",
"JOB_QUEUE_PRIORITY": "",
"JOB_END_SEVERITY": 30
},
{
"JOB_STATUS": "OUTQ",
"JOB_QUEUE_NAME": "IBMSAJOBQ",
"JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
"JOB_TYPE": "BCH",
"JOB_ACCOUNTING_CODE": "IBM 123385 897",
"CCSID": 37,
"JOB_END_TIME": "2023-02-18 05:01:32",
"SUBMITTER_JOB_NAME": "915387/QUSER/QSQSRVR",
"JOB_ENTERED_SYSTEM_TIME": "2023-02-18 05:00:28",
"JOB_DESCRIPTION": "ISYSJOBD",
"JOB_INFORMATION": "YES",
"JOB_NAME": "932558/MSRXS/ISYSJOBD",
"JOB_TYPE_ENHANCED": "BATCH",
"COMPLETION_STATUS": "NORMAL",
"JOB_DATE": "",
"JOB_ACTIVE_TIME": "2023-02-18 05:01:32",
"JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
"JOB_QUEUE_STATUS": "RELEASED",
"SUBMITTER_MESSAGE_QUEUE": "MSRXS",
"JOB_SUBSYSTEM": "",
"SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
"JOB_SCHEDULED_TIME": "",
"JOB_END_REASON": "JOB ENDING IN NORMAL MANNER",
"JOB_QUEUE_PRIORITY": "",
"JOB_END_SEVERITY": 30
},
{
"JOB_STATUS": "OUTQ",
"JOB_QUEUE_NAME": "IBMSAJOBQ",
"JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
"JOB_TYPE": "BCH",
"JOB_ACCOUNTING_CODE": "IBM 123385 897",
"CCSID": 37,
"JOB_END_TIME": "2023-02-18 05:03:13",
"SUBMITTER_JOB_NAME": "915387/QUSER/QSQSRVR",
"JOB_ENTERED_SYSTEM_TIME": "2023-02-18 05:03:12",
"JOB_DESCRIPTION": "ISYSJOBD",
"JOB_INFORMATION": "YES",
"JOB_NAME": "932641/MSRXS/ISYSJOBD",
"JOB_TYPE_ENHANCED": "BATCH",
"COMPLETION_STATUS": "NORMAL",
"JOB_DATE": "",
"JOB_ACTIVE_TIME": "2023-02-18 05:03:12",
"JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
"JOB_QUEUE_STATUS": "RELEASED",
"SUBMITTER_MESSAGE_QUEUE": "MSRXS",
"JOB_SUBSYSTEM": "",
"SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
"JOB_SCHEDULED_TIME": "",
"JOB_END_REASON": "JOB ENDING IN NORMAL MANNER",
"JOB_QUEUE_PRIORITY": "",
"JOB_END_SEVERITY": 30
}
],
"start": "2023-02-18 05:03:14.707204",
"delta": "0:00:00.088799",
"rc": 0
},
"changed": false,
"_ansible_verbose_always": true,
"_ansible_no_log": false
}
I tried changing the syntax of fourth tasks in various ways. But it keeps failing.

Your choice of variable names makes this look more confusing. the ibm.power_ibmi.ibmi_job documents these return values. As you see it will retrun you a dict of which there will be an attribute job_info which is a list. Since your register your task output also as job_info you would need to access it as
- name: Print the job name or names
debug:
msg: "{{ job_info.[\"job_info\"][0][\"JOB_NAME\"] }}"
since the first job_info is the name of your var, then the second job info is an attribute of the dict which is your var. then you will be able to access the list using index [0] then lastly lookup then job name from the first index

Related

How to use json_query against a output stored in a registered variable in Ansible?

I am writing an Ansible role to fetch current details of Audit settings from SQL Server through ansible.windoww.win_powershell module. In doing so, I am trying to use json_query in Ansible that has the following structure in the output but json_query is returning empty values. Please help.
This is the Ansible task:
- name: Sample Test debug:
msg: "{{list_of_audit_actions.output}}"
This variable list_of_audit_actions.output has this structure:
"msg": [
{
"HasErrors": false,
"ItemArray": [
"Test-Audit_Specification_SCM",
"AUDIT_CHANGE_GROUP",
"SUCCESS AND FAILURE",
"APPLICATION LOG"
],
"RowError": "",
"RowState": {
"String": "Detached",
"Type": "System.Data.DataRowState",
"Value": 1
},
"Table": {
"CaseSensitive": false,
"ChildRelations": "",
"Columns": "name audit_action_name audited_result type_desc",
"Constraints": "",
"Container": null,
"ContainsListCollection": false,
"DataSet": null,
"DefaultView": "",
"DesignMode": false,
"DisplayExpression": "",
"ExtendedProperties": "System.Data.PropertyCollection",
"HasErrors": false,
"IsInitialized": true,
"Locale": "en-GB",
"MinimumCapacity": 50,
"Namespace": "",
"ParentRelations": "",
"Prefix": "",
"PrimaryKey": "",
"RemotingFormat": 0,
"Rows": "",
"Site": null,
"TableName": ""
},
"audit_action_name": "AUDIT_CHANGE_GROUP",
"audited_result": "SUCCESS AND FAILURE",
"name": "Test-Audit_Specification_SCM",
"type_desc": "APPLICATION LOG"
},
{
"HasErrors": false,
"ItemArray": [
"TestAuditSpec1",
"AUDIT_CHANGE_GROUP",
"SUCCESS AND FAILURE",
"APPLICATION LOG"
],
"RowError": "",
"RowState": {
"String": "Detached",
"Type": "System.Data.DataRowState",
"Value": 1
},
"Table": {
"CaseSensitive": false,
"ChildRelations": "",
"Columns": "name audit_action_name audited_result type_desc",
"Constraints": "",
"Container": null,
"ContainsListCollection": false,
"DataSet": null,
"DefaultView": "",
"DesignMode": false,
"DisplayExpression": "",
"ExtendedProperties": "System.Data.PropertyCollection",
"HasErrors": false,
"IsInitialized": true,
"Locale": "en-GB",
"MinimumCapacity": 50,
"Namespace": "",
"ParentRelations": "",
"Prefix": "",
"PrimaryKey": "",
"RemotingFormat": 0,
"Rows": "",
"Site": null,
"TableName": ""
},
"audit_action_name": "AUDIT_CHANGE_GROUP",
"audited_result": "SUCCESS AND FAILURE",
"name": "TestAuditSpec1",
"type_desc": "APPLICATION LOG"
},
{
"HasErrors": false,
"ItemArray": [
"TestAuditSpec1",
"FAILED_LOGIN_GROUP",
"SUCCESS AND FAILURE",
"APPLICATION LOG"
],
"RowError": "",
"RowState": {
"String": "Detached",
"Type": "System.Data.DataRowState",
"Value": 1
},
"Table": {
"CaseSensitive": false,
"ChildRelations": "",
"Columns": "name audit_action_name audited_result type_desc",
"Constraints": "",
"Container": null,
"ContainsListCollection": false,
"DataSet": null,
"DefaultView": "",
"DesignMode": false,
"DisplayExpression": "",
"ExtendedProperties": "System.Data.PropertyCollection",
"HasErrors": false,
"IsInitialized": true,
"Locale": "en-GB",
"MinimumCapacity": 50,
"Namespace": "",
"ParentRelations": "",
"Prefix": "",
"PrimaryKey": "",
"RemotingFormat": 0,
"Rows": "",
"Site": null,
"TableName": ""
},
"audit_action_name": "FAILED_LOGIN_GROUP",
"audited_result": "SUCCESS AND FAILURE",
"name": "TestAuditSpec1",
"type_desc": "APPLICATION LOG"
}
]
}
How do I use json_query to filter all the values of audit_action_name in the above output?
I tried something like
- name: Sample Test
debug:
msg: "{{list_of_audit_actions.output| community.general.json_query('audit_action_name')}}"
But that does not yield anything but empty output
For building a query to use with the json_query filter, I like to use the jp command line tool to experiment with queries.
The contents of list_of_audit_actions.output is a list, so a query for audit_action_name doesn't make sense -- it's not a dictionary and does not have an audit_action_name attribute.
We want to extract the audti_action_name attribute from every item in the list, which we can do like this:
- debug:
var: list_of_audit_actions.output | json_query('[].audit_action_name')
Which will produce as output:
TASK [debug] ******************************************************************************************************************************************************************************************************
ok: [localhost] => {
"list_of_audit_actions.output | json_query('[].audit_action_name')": [
"AUDIT_CHANGE_GROUP",
"AUDIT_CHANGE_GROUP",
"FAILED_LOGIN_GROUP"
]
}

How to fetch the content from same tag from GitHub Api using bash

I want to get the data of tag_name from this link
https://api.github.com/repos/checkstyle/checkstyle/releases
but as we have a lot of releases. How can I get a particular tag_name
I do
LATEST_RELEASE_TAG=$(curl -s https://api.github.com/repos/checkstyle/checkstyle/releases/latest \
| jq ".tag_name")
to get the latest tag_name but how to fetch the second tag_name?
eg:
[ {
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/73283356",
"assets_url": "https://api.github.com/repos/checkstyle/checkstyle/releases/73283356/assets",
"upload_url": "https://uploads.github.com/repos/checkstyle/checkstyle/releases/73283356/assets{?name,label}",
"html_url": "https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-10.3.2",
"id": 73283356,
"author": {
"login": "romani",
"id": 812984,
"node_id": "MDQ6VXNlcjgxMjk4NA==",
"avatar_url": "https://avatars.githubusercontent.com/u/812984?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/romani",
"html_url": "https://github.com/romani",
"followers_url": "https://api.github.com/users/romani/followers",
"following_url": "https://api.github.com/users/romani/following{/other_user}",
"gists_url": "https://api.github.com/users/romani/gists{/gist_id}",
"starred_url": "https://api.github.com/users/romani/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/romani/subscriptions",
"organizations_url": "https://api.github.com/users/romani/orgs",
"repos_url": "https://api.github.com/users/romani/repos",
"events_url": "https://api.github.com/users/romani/events{/privacy}",
"received_events_url": "https://api.github.com/users/romani/received_events",
"type": "User",
"site_admin": false
},
"node_id": "RE_kwDOAL65M84EXjcc",
"tag_name": "checkstyle-10.3.2",
"target_commitish": "master",
"name": "",
"draft": false,
"prerelease": false,
"created_at": "2022-07-31T13:38:47Z",
"published_at": "2022-07-31T13:54:14Z",
"assets": [
{
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/assets/73245332",
"id": 73245332,
"node_id": "RA_kwDOAL65M84EXaKU",
"name": "checkstyle-10.3.2-all.jar",
"label": "",
"uploader": {
"login": "romani",
"id": 812984,
"node_id": "MDQ6VXNlcjgxMjk4NA==",
"avatar_url": "https://avatars.githubusercontent.com/u/812984?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/romani",
"html_url": "https://github.com/romani",
"followers_url": "https://api.github.com/users/romani/followers",
"following_url": "https://api.github.com/users/romani/following{/other_user}",
"gists_url": "https://api.github.com/users/romani/gists{/gist_id}",
"starred_url": "https://api.github.com/users/romani/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/romani/subscriptions",
"organizations_url": "https://api.github.com/users/romani/orgs",
"repos_url": "https://api.github.com/users/romani/repos",
"events_url": "https://api.github.com/users/romani/events{/privacy}",
"received_events_url": "https://api.github.com/users/romani/received_events",
"type": "User",
"site_admin": false
},
"content_type": "application/zip",
"state": "uploaded",
"size": 16208747,
"download_count": 505,
"created_at": "2022-07-31T13:54:16Z",
"updated_at": "2022-07-31T13:55:12Z",
"browser_download_url": "https://github.com/checkstyle/checkstyle/releases/download/checkstyle-10.3.2/checkstyle-10.3.2-all.jar"
}
],
"tarball_url": "https://api.github.com/repos/checkstyle/checkstyle/tarball/checkstyle-10.3.2",
"zipball_url": "https://api.github.com/repos/checkstyle/checkstyle/zipball/checkstyle-10.3.2",
"body": "https://checkstyle.org/releasenotes.html#Release_10.3.2\r\n\r\nBug fixes:\r\n\r\n #11736 - MissingJavadocType: Support qualified annotation names\r\n #11655 - Update google_checks.xml to have the SuppressionCommentFilter and SuppressWarningsHolder modules in the config by default (and by extension, SuppressWarningsFilter)\r\n\r\n<details>\r\n<summary>Other Changes:</summary>\r\n<br>\r\n Update releasenotes to use GitHub Pages execution\r\n<br />\r\n Allow SuppressWarningHolder to suppress the violation with NameCheck\r\n<br />\r\n Pitest: Kill all surviving mutations\r\n<br />\r\n Pitest: Activate \"ALL\" mutator group\r\n<br />\r\n Use Shellcheck to resolve violations code in Shell Script\r\n<br />\r\n pitest: increase mutation coverage for pitest-imports profile to 100% \r\n<br />\r\n Update GitHub Action for bump-license-year.sh\r\n<br />\r\n Solve fb-contrib errors\r\n<br />\r\n Remove pitest mutation checking HTML model\r\n<br />\r\n automate execution by Github action bump-license-year.sh on first day of month\r\n<br />\r\n update code base to have javadoc tag to explain noinspection tag content\r\n<br />\r\n doc: put example of enableExternalDtdLoad to xdoc\r\n<br />\r\n update doc for SuppressWarningsHolder\r\n<br />\r\n releasenotes script generated empty commit\r\n<br />\r\n Include CDG Accelerator Plugin to boost pitest performance\r\n<br />\r\n Enforce file size on Java inputs\r\n<br />\r\n Expand XPath IT Regression Testing\r\n<br />\r\n There are semantic problems in the Chinese error message of keyword `design.forExtension` .\r\n<br />\r\n prepare-settings.sh fails to create settings.xml\r\n<br />\r\n Use groovy version provided by `apt` in pitest.yml\r\n<br />\r\n tweet-releasenotes.sh does not check env variables\r\n<br />\r\n download of m2 cache from sourceforge.io is slow \r\n<br />\r\n infra: turns off create dependency reduced pom for shade plugin\r\n<br />\r\n Update Tests to use new 'verifyXxxxxx' method or 'execute' that use inlined config in Input files\r\n<br />\r\n Specify violation messages in input files.\r\n<br />\r\n pitest: increase mutation coverage for javadoc profile to 100%\r\n<br />\r\n</details>",
"reactions": {
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/73283356/reactions",
"total_count": 10,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 6,
"confused": 0,
"heart": 2,
"rocket": 2,
"eyes": 0
} }, {
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/70647006",
"assets_url": "https://api.github.com/repos/checkstyle/checkstyle/releases/70647006/assets",
"upload_url": "https://uploads.github.com/repos/checkstyle/checkstyle/releases/70647006/assets{?name,label}",
"html_url": "https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-10.3.1",
"id": 70647006,
"author": {
"login": "romani",
"id": 812984,
"node_id": "MDQ6VXNlcjgxMjk4NA==",
"avatar_url": "https://avatars.githubusercontent.com/u/812984?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/romani",
"html_url": "https://github.com/romani",
"followers_url": "https://api.github.com/users/romani/followers",
"following_url": "https://api.github.com/users/romani/following{/other_user}",
"gists_url": "https://api.github.com/users/romani/gists{/gist_id}",
"starred_url": "https://api.github.com/users/romani/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/romani/subscriptions",
"organizations_url": "https://api.github.com/users/romani/orgs",
"repos_url": "https://api.github.com/users/romani/repos",
"events_url": "https://api.github.com/users/romani/events{/privacy}",
"received_events_url": "https://api.github.com/users/romani/received_events",
"type": "User",
"site_admin": false
},
"node_id": "RE_kwDOAL65M84ENfze",
"tag_name": "checkstyle-10.3.1",
"target_commitish": "master",
"name": "",
"draft": false,
"prerelease": false,
"created_at": "2022-06-27T13:50:30Z",
"published_at": "2022-06-27T14:07:12Z",
"assets": [
{
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/assets/69790751",
"id": 69790751,
"node_id": "RA_kwDOAL65M84EKOwf",
"name": "checkstyle-10.3.1-all.jar",
"label": "",
"uploader": {
"login": "romani",
"id": 812984,
"node_id": "MDQ6VXNlcjgxMjk4NA==",
"avatar_url": "https://avatars.githubusercontent.com/u/812984?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/romani",
"html_url": "https://github.com/romani",
"followers_url": "https://api.github.com/users/romani/followers",
"following_url": "https://api.github.com/users/romani/following{/other_user}",
"gists_url": "https://api.github.com/users/romani/gists{/gist_id}",
"starred_url": "https://api.github.com/users/romani/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/romani/subscriptions",
"organizations_url": "https://api.github.com/users/romani/orgs",
"repos_url": "https://api.github.com/users/romani/repos",
"events_url": "https://api.github.com/users/romani/events{/privacy}",
"received_events_url": "https://api.github.com/users/romani/received_events",
"type": "User",
"site_admin": false
},
"content_type": "application/zip",
"state": "uploaded",
"size": 15396315,
"download_count": 3577,
"created_at": "2022-06-27T14:07:13Z",
"updated_at": "2022-06-27T14:08:06Z",
"browser_download_url": "https://github.com/checkstyle/checkstyle/releases/download/checkstyle-10.3.1/checkstyle-10.3.1-all.jar"
}
],
"tarball_url": "https://api.github.com/repos/checkstyle/checkstyle/tarball/checkstyle-10.3.1",
"zipball_url": "https://api.github.com/repos/checkstyle/checkstyle/zipball/checkstyle-10.3.1",
"body": "https://checkstyle.org/releasenotes.html#Release_10.3.1",
"reactions": {
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/70647006/reactions",
"total_count": 8,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 7,
"confused": 0,
"heart": 1,
"rocket": 0,
"eyes": 0
} },
This has 2 tag_name and I want to fetch the data of the second tag_name. Now It's like I always want the 2nd number tag_name only.
-> I want to use this tag_name as the previous release so I want the latest tag_name as the latest tag and the 2nd tag "tag_name" as the previous tag. I want to use these in a shell script.
Fetching the Two Most Recent Release
You can have the Github releases API respond with the two most recent releases, and then use jq to access all .tag_name fields in the array objects and then read them into separate bash variables, like so:
#!/bin/bash
# You only care about the latest release and previous, so you can
# pass the per_page query parameter
github_rsp="$(curl -s https://api.github.com/repos/checkstyle/checkstyle/releases?per_page=2)"
# jq lets you access multiple objects in a list
# using different syntaxes. Here, ".[].tag_name" will just
# access every tag_name field in each object of the response array
# and then we put those into an array that we then join with ";'
# We then read jq's output into two separate shell variables
# using ";' as our separator
IFS=";" read latest previous < <(jq -r '[.[].tag_name] | join(";")' <<< $github_rsp)
echo " Latest version: $latest"
echo "Previous version: $previous"
With this as output
❯ ./parse.sh
Latest version: checkstyle-10.3.2
Previous version: checkstyle-10.3.1
Also see the following for even more info about how my script works, if you need explanation beyond my notes:
jq Object Value Iterator
Github REST API - List Releases
Fetching a Single Release
Since you asked about getting any arbitrary release, if you have a tag name, you can use the Github Release-by-Tag API, where you put a specific tag into the releases API URL.
#!/bin/bash
function get_release() {
local repo="$1"
local tag="$2"
local release_url="https://api.github.com/repos/${repo}/releases/tags/${tag}"
rsp=$(curl -s -H 'Accept: application/vnd.github+json' "$release_url")
echo "$rsp"
}
get_release "checkstyle/checkstyle" "checkstyle-10.1" | jq
And running this script I get...
❯ ./single-release.sh
{
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/62869604",
"assets_url": "https://api.github.com/repos/checkstyle/checkstyle/releases/62869604/assets",
"upload_url": "https://uploads.github.com/repos/checkstyle/checkstyle/releases/62869604/assets{?name,label}",
"html_url": "https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-10.1",
"id": 62869604,
"author": {
"login": "romani",
"id": 812984,
"node_id": "MDQ6VXNlcjgxMjk4NA==",
"avatar_url": "https://avatars.githubusercontent.com/u/812984?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/romani",
"html_url": "https://github.com/romani",
"followers_url": "https://api.github.com/users/romani/followers",
"following_url": "https://api.github.com/users/romani/following{/other_user}",
"gists_url": "https://api.github.com/users/romani/gists{/gist_id}",
"starred_url": "https://api.github.com/users/romani/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/romani/subscriptions",
"organizations_url": "https://api.github.com/users/romani/orgs",
"repos_url": "https://api.github.com/users/romani/repos",
"events_url": "https://api.github.com/users/romani/events{/privacy}",
"received_events_url": "https://api.github.com/users/romani/received_events",
"type": "User",
"site_admin": false
},
"node_id": "RE_kwDOAL65M84Dv1Bk",
"tag_name": "checkstyle-10.1",
"target_commitish": "master",
"name": "",
"draft": false,
"prerelease": false,
"created_at": "2022-03-27T14:51:31Z",
"published_at": "2022-03-27T15:06:48Z",
"assets": [
{
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/assets/60754101",
"id": 60754101,
"node_id": "RA_kwDOAL65M84Dnwi1",
"name": "checkstyle-10.1-all.jar",
"label": "",
"uploader": {
"login": "romani",
"id": 812984,
"node_id": "MDQ6VXNlcjgxMjk4NA==",
"avatar_url": "https://avatars.githubusercontent.com/u/812984?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/romani",
"html_url": "https://github.com/romani",
"followers_url": "https://api.github.com/users/romani/followers",
"following_url": "https://api.github.com/users/romani/following{/other_user}",
"gists_url": "https://api.github.com/users/romani/gists{/gist_id}",
"starred_url": "https://api.github.com/users/romani/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/romani/subscriptions",
"organizations_url": "https://api.github.com/users/romani/orgs",
"repos_url": "https://api.github.com/users/romani/repos",
"events_url": "https://api.github.com/users/romani/events{/privacy}",
"received_events_url": "https://api.github.com/users/romani/received_events",
"type": "User",
"site_admin": false
},
"content_type": "application/zip",
"state": "uploaded",
"size": 13403044,
"download_count": 6227,
"created_at": "2022-03-27T15:06:49Z",
"updated_at": "2022-03-27T15:07:35Z",
"browser_download_url": "https://github.com/checkstyle/checkstyle/releases/download/checkstyle-10.1/checkstyle-10.1-all.jar"
}
],
"tarball_url": "https://api.github.com/repos/checkstyle/checkstyle/tarball/checkstyle-10.1",
"zipball_url": "https://api.github.com/repos/checkstyle/checkstyle/zipball/checkstyle-10.1",
"body": "https://checkstyle.org/releasenotes.html#Release_10.1",
"reactions": {
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/62869604/reactions",
"total_count": 4,
"+1": 1,
"-1": 0,
"laugh": 0,
"hooray": 3,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
}
}

jhipster import-jdl error in jhipster gateway app when jdl has user entity relationship

I have generated a Jhipster gateway application using jhipster version 7.6.0. Here is my yo.rc
{
"generator-jhipster": {
"applicationType": "gateway",
"authenticationType": "jwt",
"baseName": "demo",
"blueprints": [],
"buildTool": "gradle",
"cacheProvider": "no",
"clientFramework": "angularX",
"clientPackageManager": "npm",
"clientTheme": "litera",
"clientThemeVariant": "primary",
"creationTimestamp": 1645612665729,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"devServerPort": 4200,
"dtoSuffix": "DTO",
"enableGradleEnterprise": false,
"enableHibernateCache": false,
"enableSwaggerCodegen": true,
"enableTranslation": false,
"entitySuffix": "",
"jhiPrefix": "jhi",
"jhipsterVersion": "7.6.0",
"jwtSecretKey": "ZGZjMmY2NjBiOGYwNjQxZDE1MzU1MzlkY2VhOWU5ODM0MWFkOWYzZDA2NTcyNTI2ZTgxOTJlYmI2NTY0Y2JjOWNjODdjNWMyNmM4YTZkNTMyNTZhMDhkZTBlNzliYzI5YTE0OWM5ZjExNzc1YjE1YTI5ZWFiNzAzMDVkMTQwYTg=",
"languages": ["en", "fr"],
"messageBroker": "kafka",
"nativeLanguage": "en",
"otherModules": [],
"packageName": "com.demo",
"pages": [],
"prodDatabaseType": "postgresql",
"reactive": true,
"searchEngine": false,
"serverPort": "8080",
"serverSideOptions": ["messageBroker:kafka", "enableSwaggerCodegen:true"],
"serviceDiscoveryType": "eureka",
"skipCheckLengthOfIdentifier": false,
"skipFakeData": false,
"skipUserManagement": false,
"testFrameworks": [],
"websocket": false,
"withAdminUi": true
}
}
I have a app-jdl.jdl file with the following content
entity Blog {
name String required minlength(3)
handle String required minlength(2)
}
relationship ManyToOne {
Blog{user(login)} to User
}
when I run jhipster import-jdl app-jdl.jdl I get the following error
What is causing the issue and how can I fix it?
your application auth type is
"authenticationType": "jwt"
check this post it seems its not supported in jwt yet
Jhipster - JDL studio - relationship to User

File provisioner in Packer for Windows Server

Issue with File Provisioner for Windows Azure VM
We tried implementing the Packer template referring the Microsoft Docs-
https://learn.microsoft.com/en-us/azure/virtual-machines/windows/build-image-with-packer#create-azure-resource-group
Also, we replaced the script with the provisioner block
Below is the JSON script used to deploy the File Provisioner
{
builders: [{
type: "azure-arm",
"client_id": "",
"client_secret": "",
"tenant_id": "",
"subscription_id": "",
"managed_image_resource_group_name": "Packer-RG",
"managed_image_name": "myPackerImage",
"os_type": "Windows",
"image_publisher": "MicrosoftWindowsServer",
"image_offer": "WindowsServer",
"image_sku": "2016-Datacenter",
"communicator": "winrm",
"winrm_use_ssl": true,
"winrm_insecure": true,
"winrm_timeout": "5m",
"winrm_username": "packer",
"azure_tags": {
dept: "Engineering",
"task": "Image deployment"
},
"location": "East US",
"vm_size": "Standard_DS2_v2"
}],
"provisioners": [{
"type": "file",
"source": "C:/Test-1",
"destination": "C:/Test-1"
}]
}
After implementing the steps, the builds were finished but no artifacts were created.

PHPUnit: post contents of file to an endpoint

I am writing a test for an application that takes in pullrequestevents from github.
As part of that, I want to post the pullrequestevent JSON as supplied by GitHub, to ensure it is parsed and stored correctly.
but the supplied method in phpunit $this->post is expecting an array.
this is my test
public function testPullRequestEventCanBePosted()
{
$content = File::get('./sampleRequests/openPullRequest.json');
$response = $this->post('/pullrequest', $content->toArray());
$response->assertSuccessful();
}
and this is the json file
{
"action": "open",
"number": 2,
"pull_request": {
"url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1",
"id": 191568743,
"node_id": "MDExOlB1bGxSZXF1ZXN0MTkxNTY4NzQz",
"html_url": "https://github.com/Codertocat/Hello-World/pull/1",
"diff_url": "https://github.com/Codertocat/Hello-World/pull/1.diff",
"patch_url": "https://github.com/Codertocat/Hello-World/pull/1.patch",
"issue_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/1",
"number": 2,
"state": "open",
"locked": false,
"title": "Update the README with new information",
"user": {
"login": "Codertocat",
"id": 21031067,
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
"avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Codertocat",
"html_url": "https://github.com/Codertocat",
"followers_url": "https://api.github.com/users/Codertocat/followers",
"following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
"gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
"organizations_url": "https://api.github.com/users/Codertocat/orgs",
"repos_url": "https://api.github.com/users/Codertocat/repos",
"events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/Codertocat/received_events",
"type": "User",
"site_admin": false
},
"body": "This is a pretty simple change that we need to pull into master.",
"created_at": "2018-05-30T20:18:30Z",
"updated_at": "2018-05-30T20:18:50Z",
"closed_at": "2018-05-30T20:18:50Z",
"merged_at": null,
"merge_commit_sha": "414cb0069601a32b00bd122a2380cd283626a8e5",
"assignee": null,
"assignees": [
],
"requested_reviewers": [
],
"requested_teams": [
],
"labels": [
],
"milestone": null,
"commits_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/commits",
"review_comments_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/comments",
"review_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/comments{/number}",
"comments_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/1/comments",
"statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/34c5c7793cb3b279e22454cb6750c80560547b3a",
"head": {
"label": "Codertocat:changes",
"ref": "changes",
"sha": "34c5c7793cb3b279e22454cb6750c80560547b3a",
"user": {
"login": "Codertocat",
"id": 21031067,
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
"avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Codertocat",
"html_url": "https://github.com/Codertocat",
"followers_url": "https://api.github.com/users/Codertocat/followers",
"following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
"gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
"organizations_url": "https://api.github.com/users/Codertocat/orgs",
"repos_url": "https://api.github.com/users/Codertocat/repos",
"events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/Codertocat/received_events",
"type": "User",
"site_admin": false
},
"repo": {
"id": 135493233,
"node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=",
"name": "Hello-World",
"full_name": "Codertocat/Hello-World",
"owner": {
"login": "Codertocat",
"id": 21031067,
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
"avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Codertocat",
"html_url": "https://github.com/Codertocat",
"followers_url": "https://api.github.com/users/Codertocat/followers",
"following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
"gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
"organizations_url": "https://api.github.com/users/Codertocat/orgs",
"repos_url": "https://api.github.com/users/Codertocat/repos",
"events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/Codertocat/received_events",
"type": "User",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/Codertocat/Hello-World",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/Codertocat/Hello-World",
"forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks",
"keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams",
"hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks",
"issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}",
"events_url": "https://api.github.com/repos/Codertocat/Hello-World/events",
"assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}",
"branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}",
"tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags",
"blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}",
"languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages",
"stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers",
"contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors",
"subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers",
"subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription",
"commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}",
"compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges",
"archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads",
"issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}",
"pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}",
"milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}",
"notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}",
"releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}",
"deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments",
"created_at": "2018-05-30T20:18:04Z",
"updated_at": "2018-05-30T20:18:50Z",
"pushed_at": "2018-05-30T20:18:48Z",
"git_url": "git://github.com/Codertocat/Hello-World.git",
"ssh_url": "git#github.com:Codertocat/Hello-World.git",
"clone_url": "https://github.com/Codertocat/Hello-World.git",
"svn_url": "https://github.com/Codertocat/Hello-World",
"homepage": null,
"size": 0,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": true,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"open_issues_count": 1,
"license": null,
"forks": 0,
"open_issues": 1,
"watchers": 0,
"default_branch": "master"
}
},
"base": {
"label": "Codertocat:master",
"ref": "master",
"sha": "a10867b14bb761a232cd80139fbd4c0d33264240",
"user": {
"login": "Codertocat",
"id": 21031067,
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
"avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Codertocat",
"html_url": "https://github.com/Codertocat",
"followers_url": "https://api.github.com/users/Codertocat/followers",
"following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
"gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
"organizations_url": "https://api.github.com/users/Codertocat/orgs",
"repos_url": "https://api.github.com/users/Codertocat/repos",
"events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/Codertocat/received_events",
"type": "User",
"site_admin": false
},
"repo": {
"id": 135493233,
"node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=",
"name": "Hello-World",
"full_name": "Codertocat/Hello-World",
"owner": {
"login": "Codertocat",
"id": 21031067,
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
"avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Codertocat",
"html_url": "https://github.com/Codertocat",
"followers_url": "https://api.github.com/users/Codertocat/followers",
"following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
"gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
"organizations_url": "https://api.github.com/users/Codertocat/orgs",
"repos_url": "https://api.github.com/users/Codertocat/repos",
"events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/Codertocat/received_events",
"type": "User",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/Codertocat/Hello-World",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/Codertocat/Hello-World",
"forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks",
"keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams",
"hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks",
"issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}",
"events_url": "https://api.github.com/repos/Codertocat/Hello-World/events",
"assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}",
"branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}",
"tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags",
"blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}",
"languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages",
"stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers",
"contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors",
"subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers",
"subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription",
"commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}",
"compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges",
"archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads",
"issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}",
"pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}",
"milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}",
"notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}",
"releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}",
"deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments",
"created_at": "2018-05-30T20:18:04Z",
"updated_at": "2018-05-30T20:18:50Z",
"pushed_at": "2018-05-30T20:18:48Z",
"git_url": "git://github.com/Codertocat/Hello-World.git",
"ssh_url": "git#github.com:Codertocat/Hello-World.git",
"clone_url": "https://github.com/Codertocat/Hello-World.git",
"svn_url": "https://github.com/Codertocat/Hello-World",
"homepage": null,
"size": 0,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": true,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"open_issues_count": 1,
"license": null,
"forks": 0,
"open_issues": 1,
"watchers": 0,
"default_branch": "master"
}
},
"_links": {
"self": {
"href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1"
},
"html": {
"href": "https://github.com/Codertocat/Hello-World/pull/1"
},
"issue": {
"href": "https://api.github.com/repos/Codertocat/Hello-World/issues/1"
},
"comments": {
"href": "https://api.github.com/repos/Codertocat/Hello-World/issues/1/comments"
},
"review_comments": {
"href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/comments"
},
"review_comment": {
"href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/comments{/number}"
},
"commits": {
"href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/commits"
},
"statuses": {
"href": "https://api.github.com/repos/Codertocat/Hello-World/statuses/34c5c7793cb3b279e22454cb6750c80560547b3a"
}
},
"author_association": "OWNER",
"merged": false,
"mergeable": true,
"rebaseable": true,
"mergeable_state": "clean",
"merged_by": null,
"comments": 0,
"review_comments": 1,
"maintainer_can_modify": false,
"commits": 1,
"additions": 1,
"deletions": 1,
"changed_files": 1
},
"repository": {
"id": 135493233,
"node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=",
"name": "Hello-World",
"full_name": "Codertocat/Hello-World",
"owner": {
"login": "Codertocat",
"id": 21031067,
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
"avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Codertocat",
"html_url": "https://github.com/Codertocat",
"followers_url": "https://api.github.com/users/Codertocat/followers",
"following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
"gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
"organizations_url": "https://api.github.com/users/Codertocat/orgs",
"repos_url": "https://api.github.com/users/Codertocat/repos",
"events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/Codertocat/received_events",
"type": "User",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/Codertocat/Hello-World",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/Codertocat/Hello-World",
"forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks",
"keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams",
"hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks",
"issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}",
"events_url": "https://api.github.com/repos/Codertocat/Hello-World/events",
"assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}",
"branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}",
"tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags",
"blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}",
"languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages",
"stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers",
"contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors",
"subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers",
"subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription",
"commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}",
"compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges",
"archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads",
"issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}",
"pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}",
"milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}",
"notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}",
"releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}",
"deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments",
"created_at": "2018-05-30T20:18:04Z",
"updated_at": "2018-05-30T20:18:50Z",
"pushed_at": "2018-05-30T20:18:48Z",
"git_url": "git://github.com/Codertocat/Hello-World.git",
"ssh_url": "git#github.com:Codertocat/Hello-World.git",
"clone_url": "https://github.com/Codertocat/Hello-World.git",
"svn_url": "https://github.com/Codertocat/Hello-World",
"homepage": null,
"size": 0,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": true,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"open_issues_count": 1,
"license": null,
"forks": 0,
"open_issues": 1,
"watchers": 0,
"default_branch": "master"
},
"sender": {
"login": "Codertocat",
"id": 21031067,
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
"avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Codertocat",
"html_url": "https://github.com/Codertocat",
"followers_url": "https://api.github.com/users/Codertocat/followers",
"following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
"gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
"organizations_url": "https://api.github.com/users/Codertocat/orgs",
"repos_url": "https://api.github.com/users/Codertocat/repos",
"events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/Codertocat/received_events",
"type": "User",
"site_admin": false
}
}
What method do I need to use to post this to the endpoint? is it a case of installing something like guzzle?
Not sure about what results you might be getting at this point, but it looks like you are missing to decode the file contents as a proper JSON object:
// get plaintext contents from the json file stub
$plaintext = File::get('./sampleRequests/openPullRequest.json');
// decode the plaintext into an actual JSON object
$stubObject = json_decode($plaintext);
// Get the object attributes as an array instead of stdclass
$arrayContent = get_object_vars($stubObject);
$response = $this->post('/pullrequest', $arrayContent);
This is not guarantee that your test will pass, since we don't know how your endpoint should behave, but it basically points out the need of converting data to the proper type before using on the tester methods (post() in this case).

Resources