Use a transaction when creating an artifact.

Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
Check the error returned by this.