@@ -103,43 +103,53 @@ runs:
103103 while [ $attempt -le $MAX_RETRIES ]; do
104104 echo "Attesting ${target_ref} (${platform_info}) - attempt ${attempt}/${MAX_RETRIES}"
105105
106- if cosign attest \
106+ # Run cosign attest and capture both stdout and stderr, plus exit code
107+ set +e # Temporarily disable exit on error to capture output
108+ cosign attest \
107109 --yes \
108110 --predicate "$SBOM_FILE" \
109111 --type cyclonedx \
110- "$target_ref" 2>&1 | tee /tmp/cosign_output.log; then
112+ "$target_ref" > /tmp/cosign_output.log 2>&1
113+ local exit_code=$?
114+ set -e # Re-enable exit on error
115+
116+ # Show the output
117+ cat /tmp/cosign_output.log
118+
119+ # Check if attestation succeeded
120+ if [ $exit_code -eq 0 ]; then
121+ echo "✓ Attestation successful for ${target_ref} (exit code: 0)"
111122
112- # Verify attestation was created by checking for success indicators
113- if grep -q "tlog entry created\|Attestation written\|successfully" /tmp/cosign_output.log || \
114- [ ${PIPESTATUS[0]} -eq 0 ]; then
115- echo "✓ Attestation successful for ${target_ref}"
116-
117- # Additional verification: check if attestation exists in registry
118- sleep 2 # Brief delay for registry propagation
119- if cosign verify-attestation \
120- --type cyclonedx \
121- --certificate-identity-regexp=".*" \
122- --certificate-oidc-issuer-regexp=".*" \
123- "$target_ref" &>/dev/null; then
124- echo "✓ Attestation verified in registry for ${target_ref}"
125- return 0
126- else
127- echo "⚠ Attestation created but not yet visible in registry, continuing anyway"
128- return 0
129- fi
123+ # Additional verification: check if attestation exists in registry
124+ sleep 2 # Brief delay for registry propagation
125+ if cosign verify-attestation \
126+ --type cyclonedx \
127+ --certificate-identity-regexp=".*" \
128+ --certificate-oidc-issuer-regexp=".*" \
129+ "$target_ref" &>/dev/null; then
130+ echo "✓ Attestation verified in registry for ${target_ref}"
131+ return 0
132+ else
133+ echo "⚠ Attestation created but not yet visible in registry, continuing anyway"
134+ return 0
130135 fi
131136 fi
132137
133138 # If we get here, attestation failed
134- echo "✗ Attestation attempt ${attempt} failed for ${target_ref}"
139+ echo "✗ Attestation attempt ${attempt} failed for ${target_ref} (exit code: ${exit_code})"
140+ echo "=== Cosign output ==="
135141 cat /tmp/cosign_output.log || true
142+ echo "=== End of cosign output ==="
136143
137144 if [ $attempt -lt $MAX_RETRIES ]; then
138145 echo "Retrying in ${RETRY_DELAY} seconds..."
139146 sleep $RETRY_DELAY
140147 attempt=$((attempt + 1))
141148 else
142149 echo "::error::Failed to attest ${target_ref} after ${MAX_RETRIES} attempts"
150+ echo "::error::Last exit code: ${exit_code}"
151+ echo "::error::Last output:"
152+ cat /tmp/cosign_output.log || true
143153 return 1
144154 fi
145155 done
0 commit comments