| 1 |
# Copyright (c) Ansible Project |
| 2 |
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 3 |
# SPDX-License-Identifier: GPL-3.0-or-later |
| 4 |
|
| 5 |
- name: Add CUSTOM scope (run {{ run_number }}) |
| 6 |
community.general.jenkins_credential: |
| 7 |
id: "CUSTOM" |
| 8 |
type: "scope" |
| 9 |
jenkins_user: "{{ jenkins_username }}" |
| 10 |
token: "{{ token }}" |
| 11 |
description: "Custom scope credential" |
| 12 |
inc_path: |
| 13 |
- "include/path" |
| 14 |
- "include/path2" |
| 15 |
exc_path: |
| 16 |
- "exclude/path" |
| 17 |
- "exclude/path2" |
| 18 |
inc_hostname: |
| 19 |
- "included-hostname" |
| 20 |
- "included-hostname2" |
| 21 |
exc_hostname: |
| 22 |
- "excluded-hostname" |
| 23 |
- "excluded-hostname2" |
| 24 |
schemes: |
| 25 |
- "http" |
| 26 |
- "https" |
| 27 |
inc_hostname_port: |
| 28 |
- "included-hostname:7000" |
| 29 |
- "included-hostname2:7000" |
| 30 |
exc_hostname_port: |
| 31 |
- "excluded-hostname:7000" |
| 32 |
- "excluded-hostname2:7000" |
| 33 |
register: custom_scope |
| 34 |
|
| 35 |
- name: Assert CUSTOM scope changed value |
| 36 |
assert: |
| 37 |
that: |
| 38 |
- custom_scope.changed == (run_number == 1) |
| 39 |
fail_msg: "CUSTOM scope changed status incorrect on run {{ run_number }}" |
| 40 |
success_msg: "CUSTOM scope behaved correctly on run {{ run_number }}" |
| 41 |
|
| 42 |
- name: Add user_and_pass credential (run {{ run_number }}) |
| 43 |
community.general.jenkins_credential: |
| 44 |
id: "userpass-id" |
| 45 |
type: "user_and_pass" |
| 46 |
jenkins_user: "{{ jenkins_username }}" |
| 47 |
token: "{{ token }}" |
| 48 |
description: "User and password credential" |
| 49 |
username: "user1" |
| 50 |
password: "pass1" |
| 51 |
register: userpass_cred |
| 52 |
|
| 53 |
- name: Assert user_and_pass changed value |
| 54 |
assert: |
| 55 |
that: |
| 56 |
- userpass_cred.changed == (run_number == 1) |
| 57 |
fail_msg: "user_and_pass credential changed status incorrect on run {{ run_number }}" |
| 58 |
success_msg: "user_and_pass credential behaved correctly on run {{ run_number }}" |
| 59 |
|
| 60 |
- name: Add file credential to custom scope (run {{ run_number }}) |
| 61 |
community.general.jenkins_credential: |
| 62 |
id: "file-id" |
| 63 |
type: "file" |
| 64 |
jenkins_user: "{{ jenkins_username }}" |
| 65 |
token: "{{ token }}" |
| 66 |
scope: "CUSTOM" |
| 67 |
description: "File credential" |
| 68 |
file_path: "{{ output_dir }}/my-secret.pem" |
| 69 |
register: file_cred |
| 70 |
|
| 71 |
- name: Assert file credential changed value |
| 72 |
assert: |
| 73 |
that: |
| 74 |
- file_cred.changed == (run_number == 1) |
| 75 |
fail_msg: "file credential changed status incorrect on run {{ run_number }}" |
| 76 |
success_msg: "file credential behaved correctly on run {{ run_number }}" |
| 77 |
|
| 78 |
- name: Add text credential to folder (run {{ run_number }}) |
| 79 |
community.general.jenkins_credential: |
| 80 |
id: "text-id" |
| 81 |
type: "text" |
| 82 |
jenkins_user: "{{ jenkins_username }}" |
| 83 |
token: "{{ token }}" |
| 84 |
description: "Text credential" |
| 85 |
secret: "mysecrettext" |
| 86 |
location: "folder" |
| 87 |
url: "http://localhost:8080/job/test" |
| 88 |
register: text_cred |
| 89 |
|
| 90 |
- name: Assert text credential changed value |
| 91 |
assert: |
| 92 |
that: |
| 93 |
- text_cred.changed == (run_number == 1) |
| 94 |
fail_msg: "text credential changed status incorrect on run {{ run_number }}" |
| 95 |
success_msg: "text credential behaved correctly on run {{ run_number }}" |
| 96 |
|
| 97 |
- name: Add githubApp credential (run {{ run_number }}) |
| 98 |
community.general.jenkins_credential: |
| 99 |
id: "githubapp-id" |
| 100 |
type: "github_app" |
| 101 |
jenkins_user: "{{ jenkins_username }}" |
| 102 |
token: "{{ token }}" |
| 103 |
description: "GitHub app credential" |
| 104 |
appID: "12345" |
| 105 |
private_key_path: "{{ output_dir }}/github.pem" |
| 106 |
owner: "github_owner" |
| 107 |
register: githubapp_cred |
| 108 |
|
| 109 |
- name: Assert githubApp credential changed value |
| 110 |
assert: |
| 111 |
that: |
| 112 |
- githubapp_cred.changed == (run_number == 1) |
| 113 |
fail_msg: "githubApp credential changed status incorrect on run {{ run_number }}" |
| 114 |
success_msg: "githubApp credential behaved correctly on run {{ run_number }}" |
| 115 |
|
| 116 |
- name: Add sshKey credential (run {{ run_number }}) |
| 117 |
community.general.jenkins_credential: |
| 118 |
id: "sshkey-id" |
| 119 |
type: "ssh_key" |
| 120 |
jenkins_user: "{{ jenkins_username }}" |
| 121 |
token: "{{ token }}" |
| 122 |
description: "SSH key credential" |
| 123 |
username: "sshuser" |
| 124 |
private_key_path: "{{ output_dir }}/ssh_key" |
| 125 |
passphrase: 1234 |
| 126 |
register: sshkey_cred |
| 127 |
|
| 128 |
- name: Assert sshKey credential changed value |
| 129 |
assert: |
| 130 |
that: |
| 131 |
- sshkey_cred.changed == (run_number == 1) |
| 132 |
fail_msg: "sshKey credential changed status incorrect on run {{ run_number }}" |
| 133 |
success_msg: "sshKey credential behaved correctly on run {{ run_number }}" |
| 134 |
|
| 135 |
- name: Add certificate (p12) credential (run {{ run_number }}) |
| 136 |
community.general.jenkins_credential: |
| 137 |
id: "certificate-id" |
| 138 |
type: "certificate" |
| 139 |
jenkins_user: "{{ jenkins_username }}" |
| 140 |
token: "{{ token }}" |
| 141 |
description: "Certificate credential" |
| 142 |
password: "12345678901234" |
| 143 |
file_path: "{{ output_dir }}/certificate.p12" |
| 144 |
register: cert_p12_cred |
| 145 |
|
| 146 |
- name: Assert certificate (p12) credential changed value |
| 147 |
assert: |
| 148 |
that: |
| 149 |
- cert_p12_cred.changed == (run_number == 1) |
| 150 |
fail_msg: "certificate (p12) credential changed status incorrect on run {{ run_number }}" |
| 151 |
success_msg: "certificate (p12) credential behaved correctly on run {{ run_number }}" |
| 152 |
|
| 153 |
- name: Add certificate (pem) credential (run {{ run_number }}) |
| 154 |
community.general.jenkins_credential: |
| 155 |
id: "certificate-id-pem" |
| 156 |
type: "certificate" |
| 157 |
jenkins_user: "{{ jenkins_username }}" |
| 158 |
token: "{{ token }}" |
| 159 |
description: "Certificate credential (pem)" |
| 160 |
file_path: "{{ output_dir }}/cert.pem" |
| 161 |
private_key_path: "{{ output_dir }}/private.key" |
| 162 |
register: cert_pem_cred |
| 163 |
|
| 164 |
- name: Assert certificate (pem) credential changed value |
| 165 |
assert: |
| 166 |
that: |
| 167 |
- cert_pem_cred.changed == (run_number == 1) |
| 168 |
fail_msg: "certificate (pem) credential changed status incorrect on run {{ run_number }}" |
| 169 |
success_msg: "certificate (pem) credential behaved correctly on run {{ run_number }}" |